add_image_size not working

For this to work, you must have added the thumbnail support. You can use the following code in functions.php to add the support add_theme_support( ‘post-thumbnails’ ); add_image_size(‘poster-full’, 450, 9999, false); and to display the image: if ( has_post_thumbnail() ) { the_post_thumbnail(“poster-full”); }else{ echo “No thumbnail”; }

Weird encoded error when using wp_generate_attachment_metadata()

I tracked the error down through several functions to GD’s imagejpeg() function. So I checked the error log and found this: HTTP wrapper does not support writeable connections A quick search found that this resulted from using a full URL instead of a server filepath. So I changed the value of $filepath to use $wp_upload_dir[‘path’] … Read more

Add retina “2x” in attribute “srcset”

WordPress puts all resized versions of an image with the same aspect ratio into the srcset property. So if you need a “2x” image and one is not being generated already you could add an image size via add_image_size(). For the 2x image to be inserted in the correct circumstances you might need to tweak … Read more

Images don’t load erratically

I see multiple messages about images and some script blocked in Chrome with (blocked:mixed-content) reason. Which basically means it doesn’t like unsecure http resources in secure https site. WordPress doesn’t handle this particularly well. It is designed to use absolute URLs and they tend to end up hardcoded in content and such. You would have … Read more

How to apply image alt descriptions from media library?

From the Dashboard of your WordPress website, go to Media > Library You will see all of your images there. Select the image which one you want to update, and click “Edit”. The “Edit Media” page will open. Scroll down to the bottom of this page, you will be found few input boxes to provide … Read more

How to get the title of the random images from media library?

Your first function get_images_from_media_library() only returns images guid, I’d suggest to extend it by returning all image datas : function get_images_from_media_library() { $args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ =>’image’, ‘post_status’ => ‘inherit’, ‘posts_per_page’ => 6, ‘orderby’ => ‘rand’ ); $query_images = new WP_Query( $args ); $images = array(); foreach ( $query_images->posts as $image) { … Read more

How to setting up the custom size thumbnail for wp_get_attachment_thumb_url()?

I meant you should use wp_get_attachment_image_src() with your $cat_thumb_id. Try this: $cat_thumb_id = get_woocommerce_term_meta($cat->term_id, ‘thumbnail_id’, true); $cat_thumb = wp_get_attachment_image_src($cat_thumb_id, ‘medium_large’); $cat_thumb_src = $cat_thumb[0] ? esc_url($cat_thumb[0]) : mytheme_catch_that_image(); ?><img src=”https://wordpress.stackexchange.com/questions/226005/<?php echo $cat_thumb_src; ?>” alt=”<?php echo $cat->name; ?>”/>

Use default image as var

This is mostly a PHP general question about concatenating a function’s returned value with a (or many) string(s). The get_bloginfo function returns a string instead of echoing it directly. Thus you start off with: // First param value: stylesheet_directory // Using “template_url” also works unless you are using a child theme // In that case, … Read more