After ages I have decided to optimize the images on my store, to do so I have download the media folder and compressed all the images with Caesium leaving the original folder structure.
The first run left the extension unchanged, I have obtained a good file size reduction, but I have also tried to change the extension to see if any improvements can be obtained(if the size is bigger than the original, then the image is skipped): the result was a further reduction of 44Mb.

Now my problem/doubt is how can I upload back all the images and register the extension change? My first guess is to edit the table that stores these information, but I have no idea how the Magento framework store/manage these data. Is it better to avoid this kind of procedure?

  • If the images name are same then my guess is just uploading those back to media folder will work. By the way is it Magento1 or Magento2. – Kingshuk Deb Apr 11 '17 at 6:47
  • @KingshukDeb Sorry, I have added the tag for magento 1.9, the image management works independently from the extension of the image? – Razorphyn Apr 11 '17 at 6:49
  • If names are still same then just put the media folder back. You dont have to do any changes in db. – Kingshuk Deb Apr 11 '17 at 6:52

Magento stores images in the catalog_product_entity_media_gallery table. The value field should have your image name.
You can just run the query

UPDATE `catalog_product_entity_media_gallery`
    value = REPLACE(value, '.old_ext', '.new_ext')

but please backup first.

  • You surely know better but does he need to run this query if all images name are unchanged. – Kingshuk Deb Apr 11 '17 at 7:00
  • from what I understood the file extension was changed. If I understood wrong, then the query is not needed. – Marius Apr 11 '17 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.