The situation is this: I’m using Video Thumbnails plugin to automatically get and set youtube/vimeo thumbnails as post featured image. The problem is that default youtube/vimeo thumbnail sizes are just a bit smaller than my theme main content width.
So what I need is to scale them up. If I go to the Media Library, I can edit each image manually, then set my exact width and WordPress scales it up just right (I dont mind that the quality is a bit worse). So is there a way that WP would do that automatically each time an image is uploaded?
This is my defined image size: add_image_size('post-full', 688, 320, true);
Vimeo thumb size is 640×320.
You can use the native WordPress image_resize function to scale up images. WordPress provides a hook called “image_resize_dimensions” which you can use to overwrite the default cropping settings. Here is a modified function which will support scaling up:
Now hook this function like so:
Once thats done, you can use the image_resize function to scale images up or down as required.
the easiest way would be to add an image-size with 640×298, and use css to resize it. as it is just a minor scale up, the browser scaling should work quite fine.
unfortunately, all the plugins i know do not provide image upscaling, just generating of the smaller image sizes, so if you want to have the 688×320 on your server, you would have to edit one of the existing plugins.
if you have Imagick installed, you can alter your plugin in file video-thumbnails.php on line 325, generating a larger version of the thumbnail, using this code:
and let wordpress generate the smaller thumbnail from it (cutting the height). Be sure to make different Imagesizes for the different Videoplatforms in your Imagick Code!