Skip to content

Instantly share code, notes, and snippets.

@obukhow
Last active March 2, 2016 16:59
Show Gist options
  • Save obukhow/fb260c9edea405df0ce8 to your computer and use it in GitHub Desktop.
Save obukhow/fb260c9edea405df0ce8 to your computer and use it in GitHub Desktop.
Change Magento Product Images File Type

For inctance, we need to convert all .gif to .jpg

Execute next commands in teminal

> cd /vaw/www/media/catalog/product/
> for i in $(find $(pwd) -name \*.gif -print); do convert $i $(echo $i.jpg | sed s/.gif//g); done
> rm -r cache/

Then, run these sql-statements in DB

update `catalog_product_entity_varchar`
set value = REPLACE(`value`, '.gif', '.jpg') 
where `attribute_id` in 
    (SELECT `attribute_id` from `eav_attrubute`
        where `attribute_code` in ('image', 'small_image', 'thumbnail') and `entity_type_id` = 4
    )
; 
update `catalog_product_entity_media_gallery`
set `value` = REPLACE(`value`, '.gif', '.jpg'); 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment