jvelo / mayocat-shop

[RETIRED] Open source e-commerce and marketplaces made simple on the JVM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incomplete image addons in index context

nesk opened this issue · comments

On the index.html template, the context is incomplete. The products are provided with their addons but if you defined an image addon in the configuration, you will only get the filename. We should get the full URL in the raw property and an <img> tag in the display property. See below for an example:

"products" : {
    "list" : [ {

        // [...]

        "theme_addons" : {

            // [...]

            "images" : {
                "zoom" : {
                    "raw" : "abstractqc15008505.jpg",
                    "display" : "abstractqc15008505.jpg"
                },
                "cart" : {
                    "raw" : "abstracthc44661.jpg",
                    "display" : "abstracthc44661.jpg"
                }
            }
        },

        "addons" : {

            // [...]

            "images" : {
                "zoom" : {
                    "raw" : "abstractqc15008505.jpg",
                    "display" : "abstractqc15008505.jpg"
                },
                "cart" : {
                    "raw" : "abstracthc44661.jpg",
                    "display" : "abstracthc44661.jpg"
                }
            }
        }
    } ]

    // [...]

}

One more thing: why is their theme_addons AND addons?

Right now in most lists, only the featured image is loaded together with the entity (for example here on the home page : https://github.com/mayocat/mayocat-shop/blob/master/shop/catalog/internal/src/main/groovy/org/mayocat/shop/catalog/web/HomeWebView.groovy#L134)
Now that there can be addon images, we need the attachment to be loaded to compute its URL. So maybe this option AttachmentLoadingOptions.FEATURED_IMAGE_ONLY should be removed altogether and we load all attachments of an entity every time (there's a perf penalty though)