Images in a design
This page is for designers who put images on pages. It answers: where design images go and how to link them, how content images differ, and the attributes every image needs.
Contents
- Two kinds of images
- Design images with ezimage
- Any design file with ezdesign
- Images in CSS
- Content images
- Alt text and size
Two kinds of images
| Design images | Content images | |
|---|---|---|
| Who adds them | the designer, in the design | editors, in the administration |
| Where | design/<design>/images/ | the content repository (var/<site>/storage/images/) |
| How linked | ezimage / ezdesign operators | the image field, drawn in an alias |
| Examples | logo, icons, background patterns | article photos, gallery images, banners |
A logo editors must be able to change is content (an image field of a site settings object), not a design image.
Design images with ezimage
ezimage looks for the file under images/ in every design base of the cascade and returns its URL in double quotes:
<img src='logo.svg'|ezimage alt="$site.title|wash" width="160" height="40">Note: no quotes around {...} in src=; the operator adds them. The quote style is its first parameter:
| Call | Output |
|---|---|
'logo.svg'|ezimage | "/extension/mytheme/design/mytheme/images/logo.svg" |
'logo.svg'|ezimage( 'single' ) | the same in single quotes |
'logo.svg'|ezimage( 'no' ) | no quotes, for use inside a string or a data- value you quote yourself |
A file that is not found is reported as a template warning ("Image '...' does not exist in any design").
Any design file with ezdesign
ezdesign works the same way for any path inside a design base:
<link rel="icon" href='images/favicon/favicon.svg'|ezdesign type="image/svg+xml">Prefer ezcss_load for stylesheets; ezdesign is for single files that are not packed (icons, manifests,
downloads that ship with the design).
Images in CSS
Use relative paths from the stylesheet to the image:
/* design/mytheme/stylesheets/mytheme.css */
.site-header { background-image: url(../images/header-pattern.svg); }The packer rewrites the relative path when it moves the stylesheet into the cache, so the image is still found. The image must be in your design (relative paths are not looked up through the cascade).
Content images
An image field is drawn through its datatype template, in an alias (a size defined in image.ini):
attribute_view_gui attribute=$node.data_map.image image_class='medium'or, when you need the URL yourself:
def $image = $node.data_map.image.content['large']
<img src=$image.url|ezroot width="$image.width" height="$image.height" alt="$image.alternative_text|wash">
undef $imageSee Image aliases.
Alt text and size
- Every
<img>has analt. Decorative images getalt=""; images that carry meaning get a short description. For content images, the image field's alternative text is the editor's job; print it with|wash. - Give
widthandheight(or a CSSaspect-ratio), so the page does not jump while images load (Measuring CLS and LCP). - Use SVG for logos and icons, modern formats for photos (SVG images, Image performance).
Related pages
- Image aliases
- Icons in a design
- URL operators
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.