web-stories-wp icon indicating copy to clipboard operation
web-stories-wp copied to clipboard

Using a transparent PNG as a background image changes the background color when published

Open bmattb opened this issue 2 years ago • 2 comments

Bug Description

https://stories-new-wordpress-amp.pantheonsite.io/wp-admin/post.php?post=22680&action=edit#page=%25222b16d777-54a7-486f-913e-7c3a822b050b%2522

Using a PNG with a dominant color and a transparent background consistently replaces the background tranparency with the dominant color on publish, resulting in a story page that is dramatically different from what was in the editor.

This may be happening when the user uses the same image for the poster image as well.

Expected Behaviour

Steps to Reproduce

  1. Create a story page and use a PNG with a transparent background Screen Shot 2022-05-12 at 1.51.18 PM.png
  2. Preview the story, you will note that the preview shows that the background color is filled with the primary color of the image Screen Shot 2022-05-12 at 1.50.19 PM.png
  3. Publish the story and you will see the same thing happening.

Screenshots

Additional Context

  • Plugin Version:
  • WordPress Version:
  • Operating System:
  • Browser:

bmattb avatar May 12 '22 17:05 bmattb

Explanation:

When adding background media like this, we use its base color (aka average color) as the page background color. This is useful on slow internet connections because you'll already see a color while the image is loading.

Introduced in #3638 / #4766 (version 1.1.0)

To handle transparent images like this we'd probably need to detect whether there is transparency and then not add the color in that case.

A workaround would be to just use this as a regular image and not a background image.

swissspidy avatar May 30 '22 13:05 swissspidy

A workaround would be to just use this as a regular image and not a background image.

Or not use an image with transparency

swissspidy avatar Sep 16 '22 19:09 swissspidy