• Resolved fssbob

    (@fssbob)


    PNG-to-JPG Doesn’t Update Database, Disastrous Result

    I ran a bulk optimization with PNG to JPG conversion enabled. The PNG’s were successfully converted to JPG’s. However, the WordPress database wasn’t updated to reflect this. As a result, every reference to those images was broken (it was still looking for the PNG file).

    I couldn’t solve this problem by doing a database search-for-png and replace with jpg because EWWW (correctly) doesn’t replace some PNG’s (the ones with transparency).

    Was this expected behavior? If so, it seems to me the PNG to JPG conversion function would be essentially useless.

    (I believe the problem would be hidden if you don’t check “remove the original image from the server after a successful conversion”. But that would mean the site is still using the PNG’s rather than the converted JPG’s, so what was the point of the conversion?)

    Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support adamewww

    (@adamewww)

    Hi fssbob,

    That isn’t intended behaviour, no. I am thinking something must be managing or controlling your database and, as such, it’s not allowing the update to happen or manipulating your media library and the location was not standard. As our document about conversions states (specifically about this issue):
    “Only images in the Media Library can be converted. This is to avoid accidentally converting images in theme & plugin folders, or other locations where it may be more difficult to ensure that the database is updated with the new filename(s). Whichever image format is smaller is the one that will be kept. At this point, only references in the wp_posts and wp_postmeta tables are updated to point to the new image.”

    Is it possible some of these were outside of the above?

    Thread Starter fssbob

    (@fssbob)

    Glad to hear it’s not expected behavior!

    The images are all definitely in the Media Library, in the /uploads/year/month folders.

    I’ll need to do some diagnostic work as soon as I have time. I’ll respond here once I’ve done that.

    Thanks for the quick response.

    Bob

    Plugin Support adamewww

    (@adamewww)

    OK, let us know!

    Thread Starter fssbob

    (@fssbob)

    I tried uploading a PNG file with the conversion option on. It was converted correctly as was the database reference. So far so good.

    Next, I wanted to test whether the failure to update the database was only happening in the case of a bulk update. I unchecked PNG to JPG conversion on the Convert tab of the Settings page and saved changes. Then I attempted to upload another test PNG that I would run a bulk convert on as a second step. However, I wasn’t able to get to the second step, because on upload EWWW is still converting the PNG even though that setting is nominally off. I tried doing the same on a second site and had the same problem–it appears that once PNG to JPG conversion has been activated, I’m unable to turn it off (even though the admin says it’s turned off.)

    Plugin Support adamewww

    (@adamewww)

    It could be that it’s the file and not that setting. Our plugin will automatically convert a PNG that meets the following limits (as it would be better suited to be a JPG):
    – The PNG image is over 300kb — that’s a good clue the image isn’t suited to be in the PNG format.
    – The PNG image does not have transparency, since JPG doesn’t support it.
    – Converting to JPG produces a smaller image.

    You can turn that off with an override, however, if it’s all three of those things, it’s probably a good indicator that that image should be a JPG and not a PNG.
    This is the override from https://docs.ewww.io/article/40-override-options
    you would add to your wp_config.php:
    define(‘EWWW_IMAGE_OPTIMIZER_DISABLE_AUTOCONVERT’, true);

    Thread Starter fssbob

    (@fssbob)

    Thanks, I think that explains why the PNG was still getting converted, and good to know about the override options.

    Fortunately or unfortunately, I still haven’t been able to duplicate the original problem. It’s definitely not happening when I update images on the fly. I guess I’m going to have to go back to a backup before the problem occurred, restore it to a test site, and re-run the batch process.

    • This reply was modified 3 years, 9 months ago by fssbob.
    • This reply was modified 3 years, 9 months ago by fssbob.
    • This reply was modified 3 years, 9 months ago by fssbob.
    Thread Starter fssbob

    (@fssbob)

    OK, I think I’ve finally isolated the source of the problem. It’s a problematic interaction with Beaver Builder. The good news is that it doesn’t impact adding NEW PNGs in Beaver Builder–only converting old ones.

    In a nutshell, EWWW properly converts the media library entry. However, Beaver Builder doesn’t realize the conversion has taken place, and still references the old PNG. (It also stops producing the srcset tag and some other img info.)

    I can fix this image-by-image by accessing the Beaver Builder entry and making a dummy change to it (e.g., changing the thumbnail size and then changing it back). But that’s not realistic when thousands of images are being converted. So it appears to me that, currently, Beaver Builder pages are not compatible with EWWW bulk PNG-to-JPG conversion.

    I’m going to share this information with Beaver Builder support as well.

    Thanks.

    Plugin Support adamewww

    (@adamewww)

    Thanks for the feedback about this! I ran it by Shane to get his take and he said he’s not terribly surprised. He said he’s seen a few page builders storing page content outside the wp_posts table, often in the wp_postmeta table, serialized and next to impossible to do anything with. If the Beaver Builder devs want to contact us (https://ewww.io/contact-us/) and provide info on working with their data (where it’s stored, what format, etc.) then perhaps we can update the URLs without breaking the content (probably not a quick fix but we will add it to our queue).

    Thread Starter fssbob

    (@fssbob)

    Thanks. I heard from Beaver Builder that they’re monitoring this thread, so I suspect they’ll be contacting you.

    Bob

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘PNG-to-JPG Doesn’t Update Database, Disastrous Result’ is closed to new replies.