Wordpress: How to prevent auto generation imgs with all possible demnisions - wordpress

Wordpress auto generates images with all possible demnisions..
For example: generate thumbnail, medium, large etc
How I can make wordpress produce images only on demant.
For example if I want only have the thumbnail size for one image, then the only images which are created will be only the original size and the thumbnail size. For other image, maybe I will want only the original kai medium size..
Is it possible to do something like that?
I don't talk about unset function..
Sorry for my English!

That's how WordPress works, it's native behaviour, it generates all possible thumbnails of the image so it can be loaded in any size when needed. In other words, thumbnails are generated when uploading image and not when showing in (on-demand concept).

Related

Wordpress: choose an image size when creating an image gallery

Goal: When creating an image gallery in Wordpress 5.3.2 using the Gutenberg editor, I'd like to be able to select the image size.
Why: The block gallery automatically serves the large image and then relies on CSS to resize the image to fit the flexbox layout. Instead I'd like to choose the medium size for my site, which is closer in size to what's displayed in the layout. This will improve load times, as users aren't being served oversized images.
Question: Is there some code I can add to functions.php that will give me the option to choose the image size I want or to override the default large size for the medium size?
I understand what you're going for and unfortunately WordPress and Gutenberg still loads the full-size, original image (and just resizes it in css) :(
There are several closely-related issues that describe this
https://core.trac.wordpress.org/ticket/45407
https://github.com/WordPress/gutenberg/issues/9620
https://github.com/WordPress/gutenberg/issues/6177
Update, 2021:
Gutenberg no longer loads the full-size, original image and you can choose which in the block's right side panel which of the registered image sizes to load;
but that image is often still larger than necessary and not fully optimized; more information at https://gist.github.com/skorasaurus/a01249d4302226bf12c80dd979322303

How to limit image download size in WordPress responsive images?

I'm using the following attachment image sizes in my theme: "thumbnail" (320) "medium" (640), "medium_large" (768) and "large" (1280).
The default WordPress "srcset" and "sizes" attributes on the tags are causing the browser to download unnecessarily large images in large viewports. For example, some of my layouts display the images in a grid with multiple columns, so it's not necessary to load the largest version of the image in these cases.
Is there a way for me to specify the maximum image size that should be downloaded?
Specifically, I tried looking for a way to customize the "srcset" attribute to exclude anything larger than 768px, but can't seem to figure out how to do this.
Any advice is really appreciated.
Try
apply_filters( 'max_srcset_image_width',int $max_width,array $size_array )
https://developer.wordpress.org/reference/hooks/max_srcset_image_width
More notes and hooks: https://make.wordpress.org/core/2015/11/10/responsive-images-in-wordpress-4-4/

Banner image being cropped

I'm trying to add images to a banner that was included with the WordPress template I'm using, but it's cropping the images instead of scaling them properly.
I noticed that the height of the banner was too small, but I can't seem to be able to change it in the CSS code.
This is the page where I'm trying to sort out the banner - Money Matters Home, and this is the original image that I uploaded - home-banner-1.png
As you can see, it's being cropped from the original, despite the fact that I've tried to change the height of the banner. The original image dimensions are 900 x 278, and it should scale naturally to 1152 x 355, but isn't.
Does anyone know how to sort this out? I feel like I'm missing something really obvious here!
You could just re-size the image in Photoshop or Gimp to the exact dimensions of the WordPress header.
Use your browsers developer inspect tool to figure out the exact dimensions.
Change dimensions of your image first to 870x230 (as i see the dimensions of current banner) - you can do it in Photoshop or even Paint.
Then when you upload image in Wordpress via Uploader, Upload the Image file and Select "Original" option in Size of image before saving rather than small/medium/large etc
Your current image banner file is: http://bojomedia.co.uk/preview/moneymatters/wp-content/uploads/2013/08/home-banner-1-temp-870x230.png
note 870x230 at the end of that file name - This is wordpress generated cropped version of original file that's being used there.
I hope this helps.

Resize the Images Created from Bytes

I have multiple images on my website. But the images generate from bytes stored in the database. I generated the images from the byes and displaying it on my website. But he size of the images are very large(70 kg)per image. This is making slow down my site.
Is There any way to resize these images (12 kg). Please help me if anyone have solution.
Thanks in advance
You can create a custom handler that can create and return image. Along with that handler should set the changeability settings etc along with image re-sizing in order to get performance improvements.
Here is the one for example: http://webimageresizer.codeplex.com/
// Returns the image mapping to /bla.jpg resized to width of 100 pixels preserving aspect relative to height
http://webimageresizer.codeplex.com/ImageHandler.ashx?src=/bla.jpg&width=100
Let me know if you need more help.

Controlling Image Size for Posts in WordPress

I've been playing around with WordPress. As a programmer, the media library seems a little strange to me - but I'm keen to understand how I can achieve what I need with the framework. Cue WordPress enthusiasts...
I need to force my WordPress post images to be a certain size. I'm not talking about the thumbnail size, which I've found can be easily manipulated within the loop, but the images that actually get inserted into a post, amongst the writing and the other media. I have a fixed content width, and I would like the images to reflect that width (uncropped).
Obviously, I could run some sort of Regular Expression that could identify the image tags, and replace them with new sizes, but is there really no other way of forcing image sizes within the post while retaining there position amongst the formatted writing that comes with it?
So far, I'm guessing that there is a CSS property out there that is used by WordPress in all images. At a push, I'm willing to go with this - whatever it may be (answer needed). But I was hoping that their might be some more involved code (perhaps something I could plop into the functions.php file) which could actually force any inserted post images to be a certain width.
Any thoughts on this would be much appreciated.
If that's only about limiting the max width of an image and prevent an image from overflow, you could use the $content_width variable in your theme:
https://wordpress.stackexchange.com/questions/6499/how-to-create-a-conditional-content-width-for-a-wordpress-theme

Resources