craftcms / craftcms/cms

Image transforms don't include focalpoints by default

Open
#7,116 7 comments 1 reaction 1 assignee View on GitHub

@andris-sevcenko is already working on this.

Since Nov 11, 2020.

bug
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

Description

There appears to be some inconsistencies with how focalpoints are used. If I recall, focalpoints used to be applied by default anytime you asked for a URL with specific dimensions. This no longer appears to be the case (assuming it ever was). To make matters more confusing, it appears that calling getSrcset does include the focalpoint by default.

Steps to reproduce

We're using the following code to generate an image tag:

{% do image.setTransform({ width: 352, height: 172 }) %}
        {{ tag('img', {
            class: 'lazyload',
            'data-src': image.url,
            width: image.width,
            height: image.height,
            'data-srcset': image.getSrcset(['1.5x', '2x'])
        }) }}

The result is that the src has a url with a 0.5,0.5 focalpoint set; however, each of the srcsets has a focalpoint set correctly to 0.9415,0.9476.

Additional info
  • Craft version: Pro 3.5.15.1
  • PHP version: 7.4.9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.