Height set to 0 when using "Scale"

Created on 11 May 2021, almost 4 years ago
Updated 13 September 2023, over 1 year ago

Problem/Motivation

We're getting correctly scaled images based on width, but the height isn't scaling and cropping. The image style is recording height as 0. Looks like the JavaScript code is hard setting the height to 0. Changing this to el.offsetHeight seems to work, however then the "Minimum difference per image style" setting doesn't appear to apply to it (getting lots of image styles with varying heights.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Closed: outdated

Version

2.0

Component

Code

Created by

🇺🇸United States greenskin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇧🇪Belgium weseze

    Closing because this ticket has become stale and outdated. Feel free to reopen if this is stil an issue thad needs fixing.

  • 🇮🇹Italy finex

    Hi, I've at least two use cases where a dynamic crop would be useful.

    Example 1:

    In my first scenario I've a text block near an image. The image needs to be cutted on top and on bottom in order to have equal height to the text. Using CSS it works fine (grid + object fit cover) but the real image size is bigger in one dimension or in the other.

    I don't know the image ratio because it depends from the text len. Simply scaling or using a "backound" option on drimage is not correct in this particolar case.

    Example 2:

    I've another use case: a gallery with columns with different sizes and on each row the images needs to have the same height. Let's explain better: consider a css grid with columns like 1/6+1/6+2/3, the images heights are 100% to the grid with object-fit cover. Now imagine that all the images are in landscape, let's say a common 16:9 format, the third one will be scaled and the quality will be fine, the first two instead, with the current implementation (and using "scale") will be scaled to a correct size but, due to the height 100%, the quality will be poor because the aspect ratio is very different.

    My current solution (work in progress):

    I'm trying to implement a new option called "Dynamic aspect ratio crop". It is simply a copy of scale but with el.offsetHeight().

    The initial tests are fine and it allows me to cover all the cases.

    I'm also using all the existing modes in other cases and they works very well. This is the last feature to cover all my needing :-)

Production build 0.71.5 2024