trafford1240 is there any way to have a white background as default for images or for PNG images please?
Ok, so this is how PHP by default handles transparent areas in PNG images when resizing and converting to JPG (which doesn't support transparency). There is a solution to replace "black" with "white" when resizing, but first of all, another issue you may need to consider ... What happens when you click to view the transparent image in the POPUP? The original PNG will retain it's transparency, in which case it will display on top of the default almost-black popup background. As far as I can see, you therefore have two related issues, which need to get resolved separately:
1. Resized PNG images transparency is converted to black.
To fix resized images, I tested some quick code. Open index.php
and find the following around line 741
:
$new_image = imagecreatetruecolor($resize_width, $resize_height);
Add below it code that adds a white background instead of black:
$new_image = imagecreatetruecolor($resize_width, $resize_height);
$color = imagecolorallocate($new_image, 255, 255, 255);
imagefill($new_image, 0, 0, $color);
* For this to apply on existing preview images, you would need to empty the cache or rename the originals.
2. Full size PNG image is displayed over black background.
We don't modify your original PNG images of course, so here you would need to change the background color of the popup. When you do this, it will also affect everything else that opens in the popup, including non-PNG images. To do this, create a file (see custom styling) _files/css/custom.css
and add:
.pswp__bg {
--popup-bg: #FFF;
}