On a listings page we can pass through an image from the admin using the combination
variable in the listings.twig
view. The combination is the data model that holds the information for the particular listings page being viewed - since listings can be made up of a category, a manufacturer or both.
We'll output the entire image block:
{{ combination.image_block | raw }}
However we'll need to pass some sizes:
{{ combination.image_block.render({
sizes: {
small: {
width: 360,
height: 360,
},
medium: {
width: 1024,
height: 540,
},
large: {
width: 1920,
height: 900,
},
},
}) | raw }}
Finally we can add some styling to our header to create a nice component for our theme (optional):
<div class="aero-listing-header flex flex-col lg:flex-row gap-4 lg:gap-8">
<div class="aero-listing-header__image w-full lg:flex-1">
{{ combination.image_block.render({sizes: {small: {width: 360, height: 360}, medium: {width: 1024, height: 540}, large: {width: 1920, height: 900}}}) | raw }}
</div>
<div class="aero-listing-header__content">
<h1 class="aero-listing-header__title text-xl lg:text-3xl">
<template v-if="search_term">Search for "{{ "{{ search_term }}" }}"</template>
<template v-else>{{ "{{ heading }}" }}</template>
</h1>
</div>
</div>