New answers tagged image-size
You can try to crop the image in places you want manually using the WP_Image_Editor class. Here is a simple example $image = 'http://karunshakya.com.np/wp-content/themes/twentyeleven/images/headers/lanterns.jpg'; $img_size = getimagesize($image); $img_process = wp_get_image_editor( $image ); // Return an implementation that extends ...
Having a solution: First register thumbnail size in function.php add_image_size( 'cp-thumb', 600, 339, true ); // (cropped) Generate thumbnail while uploading image. Then call it in post loop in following way: <div class="outer-div"> <div class="inner-div"> <?php get_the_post_thumbnail( $thumbnail->ID, 'cp-thumb' ); ?> ...
The issue is that when I upload an image that is less than the dimensions 600x339 in either height or width, they show up incorrectly on the page. I did not understand this statement as you wrote it, but when I started researching I found what you meant, so I am writing this answer to document this for others who do not understand your meaning, or how ...
It's because wordpress do not use upscale for thumbnails by default. You could use this plugin to solve this problem: https://wordpress.org/plugins/thumbnail-upscale/ It will affect only new uploaded images. To regenerate your old images use this plugin: https://wordpress.org/plugins/regenerate-thumbnails/
Try this code $crop = array( 'center', 'center' ); $resize_img->resize( $wpc_image_width, $wpc_image_height, $crop);
It sounds like your problem occurs before the image is cropped/ resized and displayed in the page - the original image is too small. You can require minimum dimensions for uploaded images, see: How to Require a Minimum Image Dimension for Uploading? Then, to resize the uploaded image without cropping it, define the image size with a 'soft crop' using ...
I think you have to follow Fighting Duplicate Image OR use Force Regenerate Thumbnails this plugin will remove all old image and generate new one OR if you choose that blog suggestion then it will have plugin with some detail wording. Feel free to contact me if any query/concern regarding this. Thanks!
If you have access to install, or if it is available on your server I would recommend using WP-CLI. It has a command to regenerate the media: wp media regenerate If not, you can try a plugin such as Regenerate Thumbnails Good luck!
The way I would do this would be to inline the background: url(...) property. <?php if ( has_post_thumbnail() ) : $hero = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'hero', '' ); $tablet = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID), 'tablet', '' ); $phablet = wp_get_attachment_image_src( ...
Top 50 recent answers are included