How do I stop multiple images in WordPress? - wordpress

I want to stop generating multiple images in wordPress.
I tried to set height & width to 0 in settings>media.
Secondly, there is no option of images size in function.php (in my wordpress theme).
Please help me

Wordpress has a filter built in to modify this behavior, just add this function to your functions.php file
add_filter('intermediate_image_sizes_advanced',' prefix_remove_default_images');
// This will remove the default image sizes and the medium_large size.
function prefix_remove_default_images( $sizes ) {
unset($sizes['small']);
unset($sizes['medium']);
unset($sizes['large']);
unset($sizes['medium_large']);
return $sizes;
}

Related

Wordpress image resize quality could be better

I do use the automatic resize function of wordpress and have already set the image quality for jpgs to a much higher quality via the functions.php file like so:
add_filter('jpeg_quality', function($arg)
{
return 90;
}
);
However, the resulting image quality is still not very good. The pictures could need a sharpening pass or a different resize algorithm.
I did not find any way to tell wordpress to use a different algorithm so far - does anyone know a hook or something similar to increase the quality?
All you need to do is paste the following code in your theme’s functions.php file or your site-specific plugin.
function gpp_jpeg_quality_callback($arg)
{
return (int)100;
}
add_filter('jpeg_quality', 'gpp_jpeg_quality_callback');
Or
add_filter( 'jpeg_quality', create_function( '', 'return 100;' ) );
You can change from admin panel .
Setting >> media >> here you can add you size for images.
for thumbnail,small ,large images .

Images of different sizes in uploads folder wordpress

When add an image in media, creates multiple images of different sizes.
When upload image.png, create image-150x112.png
I want have only image upload. How do this?
Wordpress automatically resizes the images to use as thumbnails or posts so to cut down the amount of bandwidth being used up.
If you really really want to, you can unset them but i would advise against it if your using very large images which will use up a lot bandwidth.
Option 1
Go into settings -> media and change all of the numbers to 0. This means the resize wont happen.
Option 2
Add this code to your functions.php file in the theme
function unset_image_resizing() {
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
unset( $sizes['large']);
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'unset_image_resizing');

How stop wordpress creating thumbnails?

How can I stop Wordpress from making thumbnails? It uses a lot of my nodes, and memory!
How can I do this?
PS: My Wordpress site creates 3 images per uploaded image. (and I have galleies of 20-30 images per article => sooooooooo much nodes and memory)...
It's very simple to do this...
You have no visible option "stop Wordpress making thumbnails".
You must do the following:
Go to Settings -> Media
Uncheck "Crop thumbnail to exact dimensions (normally thumbnails are proportional)" if is checked
Set at Thumbnail size, Medium size and Large size the Width and Height to 0
Now Wordpress won't create you thumbnails.
I hope this will help you!
In wordpress when you upload new image that wordpress set it's thumbnail images accoring to set from admin panel or define in theme functions file.
Here is simple way for stop generating thumbnails by simple put below code in your theme function file.
function chnage_filter_image_sizes($sizes){
$sizes = array();
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'chnage_filter_image_sizes');
Here if you want to generate own thumbnails with custome width and height whenever upload any image than just put parametes as below.
function chnage_filter_image_sizes($sizes){
$sizes = array('thumbnail_name'=>array('width'=>'120','height'=>'120','crop'=>true));
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'chnage_filter_image_sizes')

Setting thumbnail featured image size not working properly

Hi I just started today on creating my first Wordpress Theme and I am trying to create a featured Image for each post.Aldo I have managed to acomplish that it seems that the sizes I am giving it are not taking effect.Here is my code:
if(function_exists('add_theme_support')){
add_theme_support('post-thumbnails' , array('post'));
set_post_thumbnail_size(200,120);
}
if(function_exists('has_post_thumbnail') && has_post_thumbnail()){
the_post_thumbnail();
}
It seems that my featured images are not always set to the same size.For example if the image is smaller then what size I set it will remain the same , for big images the width is the same but for some the height is different.
What am I doing wrong here?
Are you setting the thumbnail size in functions.php? It will not work properly if it's just in index.php or another theme file.
From the codex:
This feature must be called before the init hook is fired. That means
it needs to be placed directly into functions.php or within a function
attached to the 'after_setup_theme' hook. For custom post types, you
can also add post thumbnails using the register_post_type function as
well.
the_post_thumbnail() displays the thumbnail and should be placed where you want the thumbnail to display.

Youtube dimensions wordpress

Is it possible to change the default embed dimensions of an youtube (or another video) in Wordpress for your current theme? I've searched for a plugin and some code, but I can't seem to find any.
What I mean is the default embed size used when you just paste an youtube url in an post or page.
Open your theme’s functions.php file, and add the following code:
if ( ! isset( $content_width ) ) $content_width = 600;
Remember to change the number 600 appropriately for your theme. It is the maximum width in pixels for your content area.
Once you do this, WordPress will automatically use that for the maximum width of your oEmbed elements (youtube videos, slideshare, etc).
via wpbeginner.com
The media settings have been removed. You can do it with a filter however.
function mycustom_embed_defaults($embed_size){
$embed_size['width'] = 600; // Adjust values to your needs
$embed_size['height'] = 500;
return $embed_size; // Return new size
}
add_filter('embed_defaults', 'mycustom_embed_defaults');
Taken from here http://shailan.com/2154/change-wordpress-default-embed-size-using-filters/
The currently accepted answer has an example that uses the following shortcode:
[youtube=http://www.youtube.com/watch?v=0Bmhjf0rKe8&w=640&h=385]
The shortcode [youtube] only works if you have the Jetpack plugin installed.
To make it work with WordPress with no Jetpack you can use the built-in [embed] shortcode like this:
[embed width=640 height=385]http://www.youtube.com/watch?v=0Bmhjf0rKe8[/embed]
To change the default embed size go to Settings > Media and just set a fixed width/height.
You also have the shortcode
[youtube=http://www.youtube.com/watch?v=0Bmhjf0rKe8&w=640&h=385]
where you can manually insert width and height as params. This shortcode will overwrite the default WP settings.
They've got rid of the fixed width/height option in the media settings of the new version of Wordpress. Not sure why. It was useful!! Shortcodes don't seem to work either.

Resources