только одно изображение из запроса

я начинаю с кодирования в OctoberCMS.

Я уже много зарабатываю, но у меня есть одна проблема, которую я не могу решить.

может быть кто-то работает и с плагином Mall?

Я использую этот код для отображения коллекции изображений в своей системе octobercms. Я использую плагин торгового центра, но мне нужна только первая картинка.

Как я могу это сделать?

{% partial __SELF__ ~ '::images' images=item.all_images %}''

это то, что я уже понял

{% partial __SELF__ ~ '::images' images=item.first%}
 {% partial __SELF__ ~ '::images' images=item.image[0]%}
    {{ item.brand_id }}<br />
    {{ item.stock }}<br />
    {{ item.category_id }}<br />    

это часть результата запроса

"image_sets":
[
    {
        "id":"12",
        "name":"fotos",
        "product_id":"13",
        "is_main_set":"1",
        "created_at":"2019-01-30 11:06:15",
        "updated_at":"2019-01-30 11:06:15",

        "images":
    [
        {
            "id":"48",
            "disk_name":"5c518522d3c97203253589.jpg",
            "file_name":"Oudenland-OU-160_actie-e1546246010172.jpg",
            "file_size":"236653","content_type":"image\/jpeg",
            "title":null,
            "description":null,
            "field":"images",
            "sort_order":"1",
            "created_at":"2019-01-30 11:06:10",
            "updated_at":"2019-01-30 11:06:15","path":"https:\/\/www.oudenland.nl\/new\/storage\/app\/uploads\/public\/5c5\/185\/22d\/5c518522d3c97203253589.jpg",
            "extension":"jpg"},{"id":"46",
            "disk_name":"5c5185221e860640905785.jpg",
            "file_name":"lastang-160.jpg",
            "file_size":"348989",
            "content_type":"image\/jpeg",
            "title":null,
            "description":null,
            "field":"images",
            "sort_order":"2",
            "created_at":"2019-01-30 11:06:10",
            "updated_at":"2019-01-30 11:06:15",
            "path":"https:\/\/www.oudenland.nl\/new\/storage\/app\/uploads\/public\/5c5\/185\/221\/5c5185221e860640905785.jpg",
            "extension":"jpg"},{"id":"45",
            "disk_name":"5c5185221df2c249730093.png",
            "file_name":"Oudenland_metal_clamp.png",
            "file_size":"1087142","content_type":"image\/png",
            "title":null,"description":null,
            "field":"images",
            "sort_order":"3","created_at":"2019-01-30 11:06:10",
            "updated_at":"2019-01-30 11:06:15","path":"https:\/\/www.oudenland.nl\/new\/storage\/app\/uploads\/public\/5c5\/185\/221\/5c5185221df2c249730093.png",
            "extension":"png"},{"id":"47",
            "disk_name":"5c518522c3d05464273058.png",
            "file_name":"Oudenland-CA-160_side.png",
            "file_size":"699668",
            "content_type":"image\/png","title":null,
            "description":null,
            "field":"images",
            "sort_order":"4",
            "created_at":"2019-01-30 11:06:10",
            "updated_at":"2019-01-30 11:06:15",
            "path":"https:\/\/www.oudenland.nl\/new\/storage\/app\/uploads\/public\/5c5\/185\/22c\/5c518522c3d05464273058.png",
            "extension":"png"
        },

        {
            "id":"49",
            "disk_name":"5c51852377318670458855.png",
            "file_name":"Oudenland-OU-160_front.png",
            "file_size":"822471","content_type":"image\/png",
            "title":null,
            "description":null,
            "field":"images",
            "sort_order":"5",
            "created_at":"2019-01-30 11:06:11",
            "updated_at":"2019-01-30 11:06:15",
            "path":"https:\/\/www.oudenland.nl\/new\/storage\/app\/uploads\/public\/5c5\/185\/237\/5c51852377318670458855.png",
            "extension":"png"
        },
        {
            "id":"50",
            "disk_name":"5c518523bbb54916275956.png",
            "file_name":"Oudenland-OU-160_strap.png",
            "file_size":"1074603",
            "content_type":"image\/png",
            "title":null,"description":null,"field":"images",
            "sort_order":"6",
            "created_at":"2019-01-30 11:06:11","updated_at":"2019-01-30 11:06:15",
            "path":"https:\/\/www.oudenland.nl\/new\/storage\/app\/uploads\/public\/5c5\/185\/23b\/5c518523bbb54916275956.png",
            "extension":"png"
        }
    ]
    }
]

    ,"prices":
    [
        {
            "id":"16",
            "price":"11500",
            "product_id":"13",
            "variant_id":null,"currency_id":"2",
            "created_at":"2019-01-30 11:03:43",
            "updated_at":"2019-01-30 11:03:43",
            "currency":{"id":"2",
            "code":"EUR",
            "symbol":"\u20ac",
            "rate":1,"decimals":"2",
            "format":"{{ currency.symbol }} {{ price|number_format(2 \".\", \"'\") }}",
            "sort_order":"2",
            "is_default":false,
            "created_at":"2019-01-25 09:51:42",
            "updated_at":"2019-01-25 13:44:57"}}],
            "variants":[],"downloads":[],"taxes":[{"id":"1",
            "name":"BTW","percentage":"21.00",
            "created_at":"2019-01-25 09:51:42",
            "updated_at":"2019-01-25 13:45:09",
            "pivot":{"product_id":"13",
            ,"tax_id":"1"}}],
            "additional_prices":[]
            }

            {
                "id":13,"category_id":"5",
                "brand_id":"1",
                "user_defined_id":"OU-160",
                "name":"Lasinverter OU-160",
"image_sets":

[
    {"id":"12","name":"fotos",
            "product_id":"13",
            "is_main_set":"1",
            "created_at":"2019-01-30 11:06:15",
            "updated_at":"2019-01-30 11:06:15",
            "images":
        [   
            {"id":"48",
            "disk_name":"5c518522d3c97203253589.jpg",
            "file_name":"Oudenland-OU-160_actie-e1546246010172.jpg",
            "file_size":"236653",
            "content_type":"image\/jpeg",
            "title":null,
            "description":null,
            "field":"images",
            "sort_order":"1",
            "created_at":"2019-01-30 11:06:10",
            "updated_at":"2019-01-30 11:06:15",
            "path":"https:\/\/www.oudenland.nl\/new\/storage\/app\/uploads\/public\/5c5\/185\/22d\/5c518522d3c97203253589.jpg","extension":"jpg"},

            {"id":"46",
            "disk_name":"5c5185221e860640905785.jpg",
            "file_name":"lastang-160.jpg",
            "file_size":"348989",
            "content_type":"image\/jpeg","title":null,"description":null,
            "field":"images","sort_order":"2",
            "created_at":"2019-01-30 11:06:10",
            "updated_at":"2019-01-30 11:06:15",
            "path":"https:\/\/www.oudenland.nl\/new\/storage\/app\/uploads\/public\/5c5\/185\/221\/5c5185221e860640905785.jpg",
            "extension":"jpg"},

            {"id":"45",
            "disk_name":"5c5185221df2c249730093.png",
            "file_name":"Oudenland_metal_clamp.png",
            "file_size":"1087142",
            "content_type":"image\/png",
            "title":null,
            "description":null,
            "field":"images",
            "sort_order":"3",
            "created_at":"2019-01-30 11:06:10",
            "updated_at":"2019-01-30 11:06:15",
            "path":"https:\/\/www.oudenland.nl\/new\/storage\/app\/uploads\/public\/5c5\/185\/221\/5c5185221df2c249730093.png",
            "extension":"png"},

            {"id":"47",
            "disk_name":"5c518522c3d05464273058.png",
            "file_name":"Oudenland-CA-160_side.png",
            "file_size":"699668",
            "content_type":"image\/png",
            "title":null,"description":null,
            "field":"images",
            "sort_order":"4",
            "created_at":"2019-01-30 11:06:10",
            "updated_at":"2019-01-30 11:06:15",
            "path":"https:\/\/www.oudenland.nl\/new\/storage\/app\/uploads\/public\/5c5\/185\/22c\/5c518522c3d05464273058.png",
            "extension":"png"},

            {"id":"49",
            "disk_name":"5c51852377318670458855.png",
            "file_name":"Oudenland-OU-160_front.png",
            "file_size":"822471",
            "content_type":"image\/png",
            "title":null,
            "description":null,
            "field":"images",
            "sort_order":"5",
            "created_at":"2019-01-30 11:06:11","updated_at":"2019-01-30 11:06:15",
            "path":"https:\/\/www.oudenland.nl\/new\/storage\/app\/uploads\/public\/5c5\/185\/237\/5c51852377318670458855.png",
            "extension":"png"},

            {"id":"50",
            "disk_name":"5c518523bbb54916275956.png",
            "file_name":"Oudenland-OU-160_strap.png",
            "file_size":"1074603",
            "content_type":"image\/png",
            "title":null,
            "description":null,
            "field":"images","sort_order":"6","created_at":"2019-01-30 11:06:11","updated_at":"2019-01-30 11:06:15",
            "path":"https:\/\/www.oudenland.nl\/new\/storage\/app\/uploads\/public\/5c5\/185\/23b\/5c518523bbb54916275956.png",
            "extension":"png"}
        ]
    }
],```

person Michael    schedule 30.01.2019    source источник
comment
Привет, ты проверил мой ответ? он у вас работает или нет?   -  person Zakir hussain    schedule 31.01.2019


Ответы (1)


Я просто просматриваю этот плагин oc-mall и узнаю, что они использовали класс для получения атрибутов изображения/изображений. вы можете пойти по этому пути и увидеть это.

OFFLINE\Mall\Classes\Traits\Images

и для отображения первого изображения. вы можете использовать это так.

<img src="{{ item.image.thumb('auto', 240) }}" alt="{{ item.name }}"/>

Пожалуйста!!!

person Zakir hussain    schedule 30.01.2019