- Issue created by @davidhernandez
- 🇮🇳India shwetaDevkate
As you can see the width is given in the img tag w=8256&
- 🇺🇸United States mglaman WI, USA
@davidhernandez can you share the asset's width/height and aspect ratio? I don't know why it'd be blown up so large.
The related code is https://git.drupalcode.org/project/acquia_dam/-/blob/1.0.x/src/EmbedCode...
$values['w'] = self::calculateScaleDimensions($image_properties['width'], self::getDimensionValue($effect['data']['width']), $effect['data']['upscale']);
We also have safeguards to prevent values bigger than 2048, so I have no idea how 8256 is being returned: https://git.drupalcode.org/project/acquia_dam/-/blob/1.0.x/src/EmbedCode...
- 🇺🇸United States davidhernandez USA
@shwetaDevkate The image tag itself has 500. The url is adding 8256.
@mglaman I inspected a little more. The 8256 is coming from the original image. I looked in Widen and the has its width listed as 8256. I tried embedding the same image twice. One with the scale image effect, and one using original image.
Using original image the tag adds h and w attributes with the sizes from Widen.
<img src="https://abc123.widen.net/content/ceaf09ae-c338-4556-82d2-84866e20b240/web/IMG.jpg" width="8256" height="5504" alt="IMG.jpg" loading="lazy">
The image display in this case because no width is added to the url as a parameter. When I open that url directly, Widen returns an image limited to 2048. So it appears to default to that as a max size.
When I use scale effect I get the tag reported, which puts width in the url. The width it gets from the source, so I something is causing it to use that value instead of the width from the effect (500.)
I have other people working on a different project that are also testing acquia_dam, and encountered the same problem, so I don't think it's my specific case.
If you are trying yourself, see if you can find an image in your Widen instance that is larger that 2048.
- 🇺🇸United States mglaman WI, USA
Weird. That's why we have this:
protected static function getDimensionValue(int $number): int { return $number > 2048 ? 2048 : $number; }
This is happening with the
image_scale
image effect? Which is set to scale to 500px width, correct? Are there any other image effects applied as well?I'm seeing that
image_resize
andfocal_point_scale_and_crop
do not guard against the> 2048
condition. - 🇺🇸United States davidhernandez USA
@mglaman Good catch on upscaling. When I remove that it works. Putting it back it breaks again, so it is the upscaling that causes the problem.
Confirming that I do not have any other effects in use. I'm testing with one at a time.
- Assigned to mglaman
- 🇺🇸United States mglaman WI, USA
I found the flaw in the test.
\Drupal\Tests\acquia_dam\Unit\EmbedCodeUrlBuilderTest::testEmbedCodeUrlBuilder
has hardcoded image properties of 100x100 and verifies image styles cannot scale over 2048. It also verifies images without image styles that are larger than 2048 are adjusted.Not what happens if the source is larger than 2048 when image style effects are present.
- Merge request !7#3340734 – Scale effect is with upscaling setting causes bad parameters, does not return image → (Open) created by mglaman
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 10:20pm 21 February 2023 - 🇺🇸United States mglaman WI, USA
@davidhernandez could you test out the patch from the MR?
- Status changed to Fixed
over 1 year ago 7:15pm 24 February 2023 Automatically closed - issue fixed for 2 weeks with no activity.