Ghost/ghost/core/test/unit/frontend/helpers
Simon Backx b7f3892be0
Added format option to img-url helper (#14962)
fixes https://github.com/TryGhost/Ghost/issues/14323

- Fixed support for resizing images from Unsplash using the `img-url` helper (previously the size property was ignored for images from Unsplash)
- Added support for `avif` file formats (supported by sharp out of the box)
- Added support for setting the format of images, with a new  `format` option:

E.g. to convert an image to webp (only works in combination with size for now, except for Unsplash where you can use it without size):
```
{{img_url @site.cover_image size="s" format="webp"}}
```

This can help improve the performance of a theme, by serving assets in `<picture>` elements with webp and fallback image formats.

Usage example:
```html
<picture>
    <source 
        srcset="{{img_url feature_image size="s" format="avif"}} 300w,
                {{img_url feature_image size="m" format="avif"}} 600w,
                {{img_url feature_image size="l" format="avif"}} 1000w,
                {{img_url feature_image size="xl" format="avif"}} 2000w"
        sizes="(min-width: 1400px) 1400px, 92vw" 
        type="image/avif"
    >
    <source 
        srcset="{{img_url feature_image size="s" format="webp"}} 300w,
                {{img_url feature_image size="m" format="webp"}} 600w,
                {{img_url feature_image size="l" format="webp"}} 1000w,
                {{img_url feature_image size="xl" format="webp"}} 2000w"
        sizes="(min-width: 1400px) 1400px, 92vw" 
        type="image/webp"
    >
    <img
        srcset="{{img_url feature_image size="s"}} 300w,
                {{img_url feature_image size="m"}} 600w,
                {{img_url feature_image size="l"}} 1000w,
                {{img_url feature_image size="xl"}} 2000w"
        sizes="(min-width: 1400px) 1400px, 92vw"
        src="{{img_url feature_image size="xl"}}"
        alt="{{#if feature_image_alt}}{{feature_image_alt}}{{else}}{{title}}{{/if}}"
    >
</picture>
```
2022-08-01 14:45:54 +02:00
..
test_tpl Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
asset.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
authors.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
body_class.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
cancel_link.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
comment_count.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
comments.test.js Updated {{comments}} helper with new options 2022-07-28 14:53:33 +01:00
concat.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
content.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
date.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
encode.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
excerpt.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
facebook_url.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
foreach.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
get.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
ghost_foot.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
ghost_head.test.js Updated frontend apps to use new config 2022-07-25 23:00:37 +05:30
has.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
img_url.test.js Added format option to img-url helper (#14962) 2022-08-01 14:45:54 +02:00
is.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
lang.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
link_class.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
link.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
match.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
meta_description.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
meta_title.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
navigation.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
next_post.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
page_url.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
pagination.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
plural.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
post_class.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
prev_post.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
price.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
raw.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
reading_time.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
t.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
tags.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
tiers.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
title.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
total_members.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
total_paid_members.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
twitter_url.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
url.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00