Images on landing pages
How to upload images to a landing page in Shoporama and show them correctly in your theme with getImages() and getSrc().
You can attach one or more images to a landing page and show them in your theme. The images are stored as an array on the landing page, so you can show all of them, only the first one, or a specific selection. This article is aimed at developers and theme builders who work directly in Smarty templates, but store owners can also benefit from the sections about uploading and alt text.
Important: There is no method called $landing_page->getImage() in the singular. Always use getImages() in the plural, which returns an array, and pick out the first image if you only need one.
Upload images to a landing page
- Go to Landing pages in your admin
- Click Edit on the landing page you want to add images to
- Use the image field to upload one or more images by dragging them in or clicking to choose them from your computer
- Write a short description for each image. The description is used as alt text and helps both screen readers and Google
- Save the page
Show images in your theme
The landing page's images are retrieved with getImages(), which returns an array of image objects. Each image has the method getSrc(width, height, type, format, quality), which generates a URL for a scaled version of the image.
Show the first image (correct pattern)
<{$images = $landing_page->getImages()}>
<{if $images}>
<{$image = $images[0]}>
<img src="<{$image->getSrc(800, 400, 'fit')}>"
alt="<{$image->getDescription()|escape}>">
<{/if}>
Show all images
<{foreach $landing_page->getImages() as $image}>
<img src="<{$image->getSrc(800, 400, 'fit')}>"
alt="<{$image->getDescription()|escape}>">
<{/foreach}>
Show only the first three images
<{foreach $landing_page->getImages() as $image name=img}>
<{if $smarty.foreach.img.iteration <= 3}>
<img src="<{$image->getSrc(600, 400, 'box')}>"
alt="<{$image->getDescription()|escape}>">
<{/if}>
<{/foreach}>
Show a hero image with a fixed crop and WebP
<{$images = $landing_page->getImages()}>
<{if $images}>
<{$image = $images[0]}>
<img src="<{$image->getSrc(1600, 700, 'box', 'webp')}>"
alt="<{$image->getDescription()|escape}>"
loading="eager">
<{/if}>
Parameters for getSrc()
- width and height: the dimensions in pixels
- type: fit (default) keeps the whole image within the given dimensions, box crops the image to the exact dimensions, and pad places the whole image on a white background in the exact dimensions without cropping
- format (optional): jpg, png, or webp. If you leave it out, Shoporama chooses the best format
- quality (optional): Shoporama always uses the store's own quality setting, so you can leave it out
Other useful image methods
- getDescription(): the image description, use it as alt text
- getFilename(): the image's original file name
- getWidth() and getHeight(): the image's original dimensions in pixels
- getHtmlSize(width, height, type): returns width and height attributes for the img tag, so the browser reserves space and the page does not shift its layout
- getInline(width, height, type, format, quality): returns the image as base64 inline data, for example for preloads or CSS backgrounds without an extra request
Open Graph image for sharing
The Open Graph image is the image that is shown when the landing page is shared on Facebook, LinkedIn, or similar sites. It is a separate field and is retrieved with getOpenGraphImage(), which returns either an image object or false.
<{if $og = $landing_page->getOpenGraphImage()}>
<meta property="og:image" content="<{$webshop->getUrl()|escape}><{$og->getSrc(1200, 630, 'box', 'jpg')}>">
<{/if}>
getSrc() returns an address without the domain, so the store's address must come first, or Facebook cannot fetch the image. If no part of the image may be cropped, use pad instead of box.
Tip: Use webp as the format for regular images to make them load faster. For Open Graph sharing, however, you should use jpg, as Facebook still handles it most reliably.
Best practices
- Upload the image in at least the size you want to show it in. Shoporama scales down, not up
- Add a description to the image in the admin. That gives you alt text and better SEO out of the box
- Always wrap getImages() in an <{if}> check before you access [0]. Otherwise an empty array will cause an error
- Use getHtmlSize to set the width and height attributes, so the page does not jump when the images load
- Add loading="lazy" to images further down the page, but not to the first hero image
Frequently asked questions
I wrote $landing_page->getImage(), but the page breaks. Why?
Because the method does not exist. On landing pages, it is called getImages() in the plural and returns an array. If you only want to use one image, write $landing_page->getImages()[0] after checking that there is at least one.
How many images can I upload to a landing page?
There is no practical limit. But remember that each extra image is an extra file the customer has to download. On a typical landing page, 1 to 5 images are plenty. If you need to show a large gallery, consider lazy loading.
Which file formats can I upload?
Shoporama accepts JPG, PNG, GIF, and WebP. When the image is shown in the store, the system automatically converts it to the format and size you request in the theme, so you can safely upload your original high-quality image.
My image description is not shown as alt text. Why?
The description is not output in the HTML automatically. In your theme, you need to retrieve it with $image->getDescription()|escape and place it in the alt attribute of the img tag. Standard themes such as Delaware already do this for you.
Can I make a gallery or a lightbox?
Yes. Loop through getImages() and create both a thumbnail and a large version of the same image with two different getSrc() calls. Then combine them in a gallery script of your choice.
How do I make a full-page hero background from a landing page image?
Use, for example, getSrc(2000, 800, 'box', 'webp') and set the image as a background-image with an inline style on a section. Choose WebP to keep the file size down on mobile.
How do I know if an Open Graph image has been uploaded?
Call $landing_page->getOpenGraphImage(). If it returns false, no separate OG image has been set. Many then choose to fall back to the first regular image with getImages()[0].
Will large landing page images hurt my Google PageSpeed score?
Yes, if you serve full-resolution images to mobile devices. Use getSrc() to request a suitable size, set width and height on the img tag, and consider combining it with srcset for responsive images. See optimizing images for mobile.
Do I need to upload a new image for each size I want to show?
No. Upload one high-resolution version, for example 2000 pixels on the longest side, and Shoporama generates all the smaller versions you request in the theme. The scaled images are cached automatically, so they are only generated the first time.
Do you need help? Contact us at support@shoporama.dk.
Related articles
How to create the most common landing pages
A guide to creating landing pages in Shoporama with rules for brands, price ranges, custom fields, and combined rules, or letting Claude set them up.
Optimize images for mobile with responsive images
A guide to using responsive images with srcset in your Shoporama theme, so mobile users get optimized images.
Sort products on a landing page
How to sort the products on a landing page in Shoporama, automatically or in your own order with drag and drop, and how to choose a default sorting...
Add a blog to your online store
A complete guide to the blog feature in Shoporama: create posts, schedule publishing, link products, optimize for search engines, and use dynamic...
Delaware theme: settings and customization
A complete guide to Delaware and DelawareDK in your Shoporama store: theme settings, footer menus, mega menu, colors, payment icons, Trustpilot,...
Related features
Advanced landing pages
Create landing pages with rules for brand, price, category, and more. Shoporama keeps the content up to date automatically. Ideal for SEO and sale...
Landing page
A landing page is a focused page built to convert visitors from ads, newsletters, and social media. Learn about types, key elements, and...
Image Archive
Collect all your images in one place. Upload once, organize them in folders, and use them on products, categories, and pages or directly in your text.