Wordpress Cropped Thumbnails Not Showing - wordpress

I'm trying to display custom cropped thumbnails in Wordpress.
Here is my code:
add_image_size('about-us-slider-image', 610, 820, true);
And in the front:
echo wp_get_attachment_image_url($imgID, 'about-us-slider-image');
But only original size is shown. Original image is larger than this dimensions and I also tried regenerating thumbnails.
The weird part is that on the server all cropped sizes are visible but not in var_dump() or anywhere else.

You have to regenerate the thumbnail after you added this code in function.php then after that it will appear like what you put the size. You have to regenerate by using this plugin.
https://wordpress.org/plugins/regenerate-thumbnails-advanced/

Related

Limit images sizes created by theme / plugins

I am trying to limit the images sizes created by themes and plugins.
For instance, if you upload an image to a woocommerce product, I only want the sizes set by woocommerce to be created.
The same for my custom slider plugin; When I upload a slider, I only want the image sizes I set for the slider custom post type to be generated.
Then, to make it more complicated, I created a couple of plugins that don't use CPT, but instead an options page (like my testimonial plugin).
I thought this may work, but it doesn't.
if( get_post_type() == 'product' ) {
add_image_size( '1280-thumb', 1280 );//1280px wide, free high
}
Thank you
Okay, first of all, do regenerate thumbnails and set your image size with same add image size function then check if the image will be cropped or not as per your custom image size try with this one.
add_image_size( 'custom-size', 220, 180, true );
Using this plugin you can do regenerate your existing thumbnails https://wordpress.org/plugins/regenerate-thumbnails/.

remove and disable featured image in posts

I write a post in new post editor and then add media. I can see the images in the editor but when i publish them they aren't loading up and a frame with little square in the middle comes up. This is the link to one of my posts: http://getprogramcode.com/2013/03/c-program-for-bit-stuffing/ . For some people only link to the image comes up and it opens up with 404 error. See the line after OUTPUT: bit stuffing.
Also i want to remove the featured image from appearing in my posts. I have a option in my theme on a new post: "disable featured image" - but that doesnt work . Also if i dont put the image or i remove the featured image the empty image appears: see the home page: http://getprogramcode.com Please help me to solve this problem
You should not use relative paths on WordPress, only Absolute paths.
The problem is that you are using ../wp-content/... as your URL's for image paths.
When adding images, you should have the option to give it a path, you should opt to link to the media file.
For the disable feature image, if you go into the page.php or single.php code, it should have a line of code in it for calling in the featured image.
It should look something like this:
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?>
You just need to remove or comment out this code and it should stop showing up on the pages.

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')

Post thumbnails won't change size

I'm listing a lot of products on one page, and untill recently I used dimensions 390px*238px. Now I have to change the dimesions to something else, I updated get_the_post_thumbnail method with new parameters, page reloads and shows everything like I wanted it to be.
But, on next refresh, everything goes back as it were. When I inspect the elements, image that is displayed indeed has class attachment-390x501, but it's width, height and src attributes show 390, 238 and path/to/website/uploads/2012/11/Profile_IS_20180-390x238.jpg.
Is there a way to change my thumbnail dimensions? Here's the code I use currently:
<?php
// previous dimensions were 390x238
echo get_the_post_thumbnail($product->ID, array(390,501));
?>
You can set the size of the thumbnails by adding a line to your functions.php file and then display the new image size.
Add this to functions.php, you can change the numbers if you need to as that is the dimensions. Also, you can repeat this line as many times as you'd like to set different size thumbnails, just change new_custom_size to a unique name for each new size.
add_image_size( 'new_custom_size', 390, 501, true );
Then display your featured image with this:
<?php the_post_thumbnail('new_custom_size'); ?>
You will need to regenerate your thumbnails once you set the size in the functions.php file and before you display it on the page/post. I highly recommend the Renegerate Thumbnails plugin for this: http://wordpress.org/extend/plugins/regenerate-thumbnails/
use add_image_size and rebuild thumbnails

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.

Resources