How to scale up featured post thumbnail?

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: function image_crop_dimensions($default, $orig_w, $orig_h, $new_w, $new_h, $crop){ if ( !$crop ) return null; // let the wordpress … Read more

Automatically replace original uploaded image with large image size

Add this to the functions.php file in the theme folder. It replaces the original image with the large image set in settings. You might want to setup a new image format and use that as the new original size though. function replace_uploaded_image($image_data) { // if there is no large image : return if (!isset($image_data[‘sizes’][‘large’])) return … Read more

What is a good alternative to using $content_width for image optimization?

Keep in mind that the $content_width global is not only used for images, but also for embedded objects, such as video. So, any solution won’t merely be a case of dropping use/support of $content_width itself. Usually a Theme will constrain content-area images in a few ways: Large Image size: Defining $content_width something appropriate for the … Read more

Function to get URL of original uploaded image – full size

There are four valid sizes built in to the WordPress core. the_post_thumbnail(‘thumbnail’); // Thumbnail (default 150px x 150px max) the_post_thumbnail(‘medium’); // Medium resolution (default 300px x 300px max) the_post_thumbnail(‘medium_large’); // Medium Large resolution (default 768px x 0(means automatic height by ratio) max) since WP version 4.4 the_post_thumbnail(‘large’); // Large resolution (default 640px x 640px max) … Read more

Image quality based on image size

The only time setting the quality really matters is right before the image is saved or streamed (for the editor). Both of these have the “image_editor_save_pre” filter there, passing it the instance of the image editor. So you can use that to modify the image in any way you like, including setting the quality. So, … Read more