You are here: All articles » Programming » Fixing no thumbnail generation in Shopware 6
-
Fixing no thumbnail generation in Shopware 6
written: 4 years ago category: Programming Next
While struggling with importing images into a Shopware database, I found the column
media.media_type
has to have a certain value, depending on the file extension (jpg, png, gif). Without a value in it,
bin/console media:generate-thumbnails
won't generate a thumbnail for this image.Now, normally you should run
bin/console media:generate-media-types --batch-size=5000
to populate this column with the right values. But this process can really eat your time - it took 2 hours for my 70,000 images. And it even gets slower on each batch offset. Be sure at least to use a bigger batch-size than the default ridiculous 50.If you have at least one image of each file extension in your media table, you can achieve the same with a very quick SQL query:
UPDATE media m1 SET media_type= (SELECT media_type FROM media WHERE file_extension=m1.file_extension AND media_type IS NOT NULL LIMIT 1) WHERE media_type IS NULL;
HeidiSQL just said:
/* Affected rows: 1.622 Found rows: 0 Warnings: 0 Duration for 1 query: 0,172 sec. */
Of course this is a hack, and there is no support for it. So be aware of what you're doing, plus make a backup before running the update
Leave a comment