911 - Help, please. I screwed up with the webp conversion and not sure how to fix it...and it needs to be fixed asap (of course).

6 posts by 4 authors in: Forums > CMS Builder
Last Post: May 31, 2023   (RSS)

By Codee - May 31, 2023 - edited: May 31, 2023

Hi Dave and the I.T. Team,

So, I had successfully  used the webp conversion on nearly 80,000 jpeg photos.  Then while prepping to move the site to a new host I basically overwrote the database unintentionally so the CMSB gallery listings reflects all of these photos as their jpeg versions, in name, but they are actually webp versions physically.  Screenshot below.  IF I go to a browser and try to view any of the images individually in a new browser window they will show if I change the file extension in the browser window to ".webp" instead of ".jpg" like the database thinks they are.

Is there a way to relatively simply correct the filenames?

I was wondering if re-running the webp converter would correct the listings...but, as you already know, it will not. Screenshot of that attached also...CMSB thinks nearly all the photos in the database are jpegs.

What if I run the webp converter on the original site still on the other host - and then just backup CMSB on the original site but then restore that backup to the site on the new host?  Wouldn't CMSB change all those file extensions in the original site's database?

Thanks in advance.

By Toledoh - May 31, 2023

Hey Codee  

i eould use the cmsb backups. you may be lucky and be able to just download the section backup, or if not then the full backup.

open the backup in a text editor, the find and replace .jpg with .webp

save as a new filename, then upload and restore.

Good luck!

Cheers,

Tim (toledoh.com.au)

By Codee - May 31, 2023 - edited: May 31, 2023

Tim,

Thank you for your suggestion ~ just what I was "thinking" but so often that's a dangerous area for me! ;-)  Perfect. *update: It worked. Don't see any errors and the gallery photos are all updated and showing. Phew! That was scary.

Terry

By Steve99 - May 31, 2023 - edited: May 31, 2023

Hi Codee,

Yes, Tim's method is straight forward and will certainly work well. 

You can also run UPDATE statements if you're comfortable. Make a backup and proceed with caution.
For example, these two statements would update the uploads table filePath and urlPath fields (finds and replaces ending .jpg with .webp):

UPDATE cmsb_uploads
SET filePath = REPLACE(filePath, '.jpg', '.webp')
WHERE filePath LIKE ('%.jpg');

UPDATE cmsb_uploads
SET urlPath = REPLACE(urlPath, '.jpg', '.webp')
WHERE urlPath LIKE ('%.jpg');

If your site uses thumbnails then you'd need to do the same process for each thumbFilePath and thumbUrlPath (thumbFilePath2 and thumbUrlPath2; etc up to 4).

To note, if all of your images were converted .jpg to .webp using the plugin this will work.
However, if you have "Use WebP" active in general settings, any new uploads appear to have the previous file type appended to the filename (ex. "myimage.jpg" would become "myimage-jpg.webp", which would require modifying the update statement replace '.webp' portion with '-jpg.webp').

Make a backup, and backup the backup :) Good luck!

Best,
Steve

P.S. I'd already started drafting this and didn't see your post update until complete :) Glad you got everything working again! I'll leave this up here in case it's useful in the future.

By Codee - May 31, 2023

Thank you, Steve. Makes great sense. I appreciate it.