Articles of add image size

Insert width & height attributes to all images displayed on each page

Using the WordPress the_content tag, I am running a custom function to search for all images that do not have a width and height attribute set and insert the proper dimensions. Below is the function: add_filter( ‘the_content’, ‘add_img_dimensions’ ); function add_img_dimensions( $image_no_dimensions ) { // Insert width & height to images missing dimensions if ( […]

Add custom image size not working

I want to add a custom image size to my child theme. The base is the Penscratch theme, and it has it own image sizes defined: function penscratch_setup() { /* … */ add_theme_support( ‘post-thumbnails’ ); add_image_size( ‘penscratch-featured’, ‘400’, ‘200’, true ); /* … */ } And if I made some changes here (base functions.php), everything […]

Image is not displayed in overridden woocommerce email

I have overridden woocommerce customer-completed-order.php <?php if ( ! defined( ‘ABSPATH’ ) ) { exit; } do_action( ‘woocommerce_email_header’, $email_heading, $email ); ?> <p><?php printf( __( “Your recent order has been completed.<br> ,’woocommerce’ ) ); ?></p> How to add image to the end of the email? I tried <?php echo wp_get_attachment_image( 1096 ,add_image_size(‘logo-size’, 219,98) ); ?> […]

Question about add_image_size()

I created an image size: add_image_size(‘slider’, 1920, 1080, true); Now, i thought hard cropping meant that WordPress would zoom into the picture until it obtains that size and proportion no matter what. Well, if User enters a vertical image, say 784×1200, What WordPress is doing is getting me an 784×1080 image, so it ignores the […]

How to extract image width from add_image_size?

How can I extract the width of an image as defined in add_image_size for use as a template variable? For example if my theme defines the size small as add_image_size( ‘small’, 195, 146, true ); 195 would be the variable. I am trying to build a dynamic mshots url.

Get post attachment images dimension and use in embed code

I am trying to make things work like where any post attachment image will generate embed code automatically. Example: If I upload and add two images 1. 250×150 2. 600 x 160 and insert into post. Now that image information I want to auto put into embed code like below. <div> <a href=”link url” title=”title […]

How to get custom image sizes into media uploader dropdown?

I searched net to solve the problem with images size uploaded from media. But not even one worked to me. When I try to insert images from the media into post it does not show my custom image size 608 X 350 px function setup_image_sizes() { if ( function_exists( ‘add_image_size’ ) ) { add_image_size( ‘post-image’, […]

Thumbnail with different sizes

I want make all my blog thumbs the size of 227×133. I need images width have 100% (for responsive design). Some images have width greater than the other and vice versa. I’m using this code to show the thumbs of my blog: / / Post thumbnails sizes add_theme_support (‘post-thumbnails’); add_image_size (‘blog-page’, 9999, 545, true); The […]

Confusion about arguments sent to add_image_size

Looking at the documentation for Cropping Thumbnails when adding new image-sizes makes me confused. Set the image size by cropping the image and defining a crop position: add_image_size( ‘custom-size’, 220, 220, array( top, left ) ); // Hard crop top left When setting a crop position, the first value in the array is the x […]

How to scale image with equal width and height without distortion?

I have a section on my frontpage that querys through recent posts and grabs the title and thumbnail of each. In my functions.php, I’ve specified a width and height for the thumbnail using: add_image_size( ‘thumbnail-small’, 179, 147 ); I have all different size images in my posts set as featured images and when they get […]