Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [add-image-size]

Registers a new image size. This means that WordPress will create a copy of the Featured Image (formerly known as post thumbnail) with the specified dimensions when you upload a new image.

0
votes
1answer
10 views

add_image_size not working with after_switch_theme

This is a weird one - this exact code works with after_setup_theme but not with after_switch_theme. Of course I would rather use after_switch_theme because after_setup_theme runs all the time - but it ...
0
votes
0answers
11 views

Soft proportional crop short side

Is it possible to soft crop an image with custom-size along the short side of the image? Right now my images are used as background of a div with background-size: cover; after they are soft-cropped ...
1
vote
0answers
219 views

wordpress responsive image srcset not working

I'm trying use wordpress core responsive image feature but it's not adding srcset to image. Here is th my codes I have a div w=370px h=280px now I added image sizes if(function_exists('...
0
votes
0answers
17 views

Something in parent theme is preventing child theme from being able to crop images

I have a dilemna where I can't crop images with add_image_size() in my child theme. Instead of cropping, the images are scaled. I've tried all the usual stuff like regenerating images and changing ...
3
votes
3answers
218 views

add_image_size is scaling, even though crop is set to true

I am trying to crop a 1000 x 648 image to 400 x 400. I use this code in functions.php add_theme_support( 'post-thumbnails' ); add_image_size('shop-size', 400, 400, array(center,center) ); ...
0
votes
0answers
19 views

Image size in browser is defaulting to fill the container despite editor / styling settings

I am in the process of building my first theme. I have built everything up slowly and have a very simple setup. Now I am stuck on something that is probably a very easy fix. Problem: When I add an ...
0
votes
0answers
245 views

Delete images for unused media image sizes, without regenerating other thumbnails

I have set 5 custom image sizes in my theme. On top of the 3 default image sizes, I have around 10 other unused image sizes from a plugin that I'm not using anymore. I want to delete the images for ...
0
votes
1answer
30 views

Change Responsive Images Maximum Width of 1600px

Sorry for my English first. Just started with responsive Images and read https://make.wordpress.org/core/2015/11/10/responsive-images-in-wordpress-4-4/ So according to this post, there is a maximum ...
0
votes
1answer
17 views

add_image_size sizes not stored

I am currently working on a function that will do the following: Checks if the parameter holds an already created image size and if this size does not exists, create a new one Loop through all the ...
0
votes
1answer
54 views

Way to store featured image width and height in two separate variables?

i have added a function like this to generate custom image size add_action( 'after_setup_theme', 'slider_image'); function slider_image(){ add_image_size( 'slide_image', 540, 405); } ...
0
votes
0answers
43 views

TwentySeventeen $content_width not updated in admin

I've read many answers to the problem of modifying TwentySeventeen's content width, but this one aspect is eluding me. I have the following in my child theme's functions.php function ...
0
votes
1answer
40 views

Custom image sizes quality

Images uploaded on my WordPress website are too heavily compressed. I found out that WordPress automatically compresses images and you can change that with a filter: add_filter( 'jpeg_quality', ...
0
votes
0answers
26 views

add_image_size via An input by user

I have a code here which is to add an image size via user input: add_action( 'after_setup_theme', 'add_size_for_featuredimage' ); function add_size_for_featuredimage() { $width_ft = esc_attr(SIO_FTP::...
2
votes
1answer
59 views

Passing srcset to image attachment method

I would like to pass values of wp_get_attachment_image_srcset to the wp_get_attachment_image method and wonder how is this possible without hardcoding the HTML image tag itself?
0
votes
0answers
414 views

Image cropping by giving my own width, height and coordinates in WordPress

I am using WordPress and currently stuck in the middle on image cropping, I got an answer from the following question Image resize with image url and it works fine to me, here is the code I am using ...
0
votes
2answers
90 views

add_image_size limiting sizes (???)

I wanted to add a new image size to the theme I have. But the image sizes are not working correctly. My code: add_theme_support( 'post-thumbnails' ); add_image_size( 'bch-microsite-slider-image', ...
0
votes
0answers
211 views

Srcset incorrect with Owl Carousel and ACF?

http://preview.kirstymarks.com/ Im looking to integrate Owl Carousel into my theme, and ive created some custom fields with ACF in conjunction with srcset. Im testing it and it appears the images ...
0
votes
1answer
81 views

Responsive Images with art direction

I've been thinking about how I would use responsive images in Wordpress. My site has a fixed height, full width thumbnail at the top of each post. The built in Wordpress implementation of responsive ...
0
votes
0answers
19 views

Best way to manage theme images

I am currently wondering what is the best way to let the user choose between a certain number of thumbnail size for the shortcodes I am building. add_image_size function is the simplest way but ...
1
vote
1answer
40 views

Is there a way to avoid using add_image_size? Best way to manage images

Currently if you have a theme that use add_image_size for let say 6 different image size you will have 6 different thumbnail created that will maybe never be used. With the current version of ...
1
vote
2answers
316 views

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 ...
1
vote
1answer
3k views

Could not load the preview image. Please reload the page and try again - error on image upload

i am getting this error "Could not load the preview image. Please reload the page and try again" whenever i upload any image on my Blog Site blog.knorish. I can see the thumbnail and image is loaded ...
0
votes
1answer
47 views

Generating very small sized thumbnails from featured image

I want to create very tiny thumbnails that I can use in my sidebar. I want them to be around 5kb in size and be created automatically from the featured images. What's the best way to do that?
6
votes
2answers
434 views

Setting JPEG compression for custom image sizes doesn't work in specific cases

I have a custom image size hello-image: add_image_size( 'hello-image', 700, 300, true ); Whenever an image is uploaded, I compress the cropped hello-image sized image to 40% JPEG compression. It ...
3
votes
1answer
81 views

add_image_size() cropped only if width of the image matches or is higher

I want to add a custom image size that is cropped, like this: add_image_size( 'large-cropped', 700, 300, true ); It works fine. The only problem is that if the image size is for example 500x400, ...
0
votes
1answer
206 views

Automatically generate multiple image sizes for <picture> element

Suppose i want to implement a responsive header with compliance for multiple devices. To do so (with a beautiful result ofc), i need different versions of the picture, resized and cropped by their ...
1
vote
2answers
1k views

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><...
1
vote
3answers
2k views

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( '...
0
votes
1answer
35 views

Image with large file size not cropping

I just set hard crop in function 676x429 hard crop. add_image_size('home-slide', 676, 429, true); Its working but client uploaded a large file something like 3800x3800 (5.73mb) and it doesn't crop. ...
0
votes
1answer
44 views

Upload image without resizing but insert in post with resizing

OK so I tried to find this problem in whole web but didn't got any solution. . basically. I have set in my Options > Media Settings : Medium size : Max Width : 500px| Max height : 500px When I ...
0
votes
1answer
543 views

Responsive images in Bootstrap 4 slider

I have a Bootstrap 4 slider in progress at https://filathlos.imagewize.com/ . When I add images of a 0.75 ratio like 2000x1500 they display and resize well. 3000x2000 works too. This with them being ...
1
vote
1answer
1k views

Crop image without scaling or resizing with add_image_size()

Both of these tend to shrink the image and then crop it to the dimensions listed. What I want is to just crop out the center of the image at 475 x 310 add_image_size( 'test', 475, 310, array( '...
0
votes
1answer
141 views

Feauterd image meta box not showing up

I Updated my wordpress from 4.6 to 4.7.2 last night and now i can see that in the post editor in admin panel there is no meta box for selecting the featured images. I also did some editing on the ...
3
votes
1answer
769 views

Wordpress won't generate image sizes for certain images

I have no idea why this particular image and others seem to be affected, but it's really annoying. I have noticed, there is one image in particular that Wordpress just will not generate different ...
1
vote
1answer
247 views

Watermark images only for some users

I have a simple thing I would like to achieve, or at least I thought it was. This is the problem/challenge: My customer uploads images for sale to a WordPress site. All images other than the original ...
0
votes
2answers
73 views

JointWP - Can't add custom images sizes [closed]

I am trying to add a custom image size in the functions.php file. add_image_size( 'Portrait', 1200, 1800, false ); add_image_size( 'Featured', 2560, 1600, true ); This is the newest version with ...
2
votes
1answer
514 views

add_image_size landscape or portrait

I've an image-oriented project. Images comes in different dimention and orientation. Based on following rules i'm generating smaller images: add_image_size('big_xxl', 4500, 9999); // 4500 x ...
0
votes
0answers
269 views

Why is image hard cropping for one image using add_image_size not working?

Why is hard cropping for the blog-grid-evensize not working? When uploading an original that is 667x596, the blog-grid-odd and blog-grid-featured sizes are correctly cropped from the left top edge. ...
0
votes
1answer
2k views

Make image full width

I am trying to make the featured image full width in my wordpress theme. I want it so that when you go to the individual posts page the featured image is full width at the top. (similar to (http://...
0
votes
1answer
27 views

How to add a new image size and apply it to posts only?

I'd like to create a new image size and write another function that basically says that if I'm applying this new image to any posts to use this new image size. function add_image_size( 'story_thumb', ...
0
votes
1answer
1k views

Get all custom sizes in srcset attribute

I have three custom sizes: add_image_size( 'img-movil', 667, 667, true ); add_image_size( 'c200x200', 200, 200, true ); add_image_size( 'c400x400', 400, 400, true ); And I'm tring to get them into ...
1
vote
0answers
93 views

How to throw admin notice error on image upload

I created a plugin that creates a new image size and turns it B&W. I need the script to throw an notice if the user upload an image smaller then 1000x1000. I tried this, but Wordpress is ...
6
votes
1answer
2k views

How can I set image sizes and still have responsive images using the srcset attribute?

I have this function in my theme to create thumbnail sizes. set_post_thumbnail_size( 620, 848, true ); if (function_exists('add_image_size')){ add_image_size( '...
2
votes
1answer
761 views

wp-cli regenerate media is not working for custom sizes

I'm using wp media regenerate to generate thumbnails. While this works for the built-in Wordpress image sizes (even when the width and height are customized in functions.php), it does not work at all ...
0
votes
1answer
149 views

Using Image Sizes for Custom Post Types outside the Loop

I want to use an image size on a Custom Post Type (which has featured image enabled). in functions.php I added: add_theme_support( 'post-thumbnails' ); add_image_size( 'my-non-working-size', 600, ...
1
vote
1answer
131 views

Add padding while generating thumbnail

I wanted to know, if there is any function to handle following case: I have registered image size of 200x200, Now if user uploads 100x100 or 800x120 the thumbnail of 200x200 will not be generated. I ...
2
votes
2answers
456 views

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: ...
0
votes
1answer
146 views

Function to insert missing image size attributes into img tags

I want to add a custom function to scan my website and automatically insert image size attributes that are missing on my pages. For example, if there is an image on one of my pages that looks like ...
8
votes
2answers
4k views

Custom image size / thumbnail - Crop to aspect ratio even when source image is smaller than set dimensions

Normally when you set a custom image size using hard crop - e.g. add_image_size( 'custom-size', 400, 400, true ); - you get the following results: #1 Uploaded image: 600x500 > Thumbnail: 400x400. #2 ...
0
votes
1answer
92 views

image sizes - finding and removing

I've inherited a wordpress site that has way too many image sizes being uploaded, several are not being used. I can't seem to find where they're being created in order to remove them. I've tried ...