Generate PNG fallback for original PNG images

Created on 1 March 2023, over 1 year ago
Updated 12 September 2023, 10 months ago

Unless I'm missing an option somewhere, it seems this module always generates jpg's, even if the original image is a png. This is problematic since png's can have transparency while jpg's cannot. Also, depending on the image, a png may be the more optimal format.

If the original image is a png, it would be preferable for the module to generate a png fallback image.

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States PCate

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

Comments & Activities

  • Issue created by @PCate
  • 🇮🇳India Meeni_Dhobale

    Hi @PCate,
    I tried the module with the png images, but I noticed that when I use a PNG image, it is already converted as PNG. Maybe I am looking somewhere else so I do not understand what you are trying to say. If you can provide some more context on it then it will be very helpful.

  • 🇺🇸United States PCate

    @Meeni_Dhobale, sorry for taking so long to reply.

    I've had time to go back and review the issue and I'm still encountering it.

    Below is the output markup I'm seeing for a uploaded PNG image:

    <img srcset="/sites/default/files/styles/card/public/images/d1ab12eac7bb/test-file.png.webp?itok=86uRvFUt 1x" width="480" height="270" src="/sites/default/files/styles/card/public/images/d1ab12eac7bb/test-file.png.jpg?itok=86uRvFUt" alt="A test image">
    

    As you can see the main srcset attribute uses the correctly generated WEBP image, but the fallback has converted the PNG image to a JPG file.

    Briefly looking at the module code at: https://git.drupalcode.org/project/wpf/-/blob/1.0.x/src/ImageFactory.php and https://git.drupalcode.org/project/wpf/-/blob/1.0.x/src/ImageFactoryInte... I see no code which handles using or generating PNG fallbacks.

  • 🇬🇧United Kingdom Ok4p1 Glasgow

    I am also experiencing this issue

  • 🇭🇺Hungary dj1999

    It is good enough me the fallback image in jpg format but waiting for patches if somebody needs an other fallback format.

Production build 0.69.0 2024