Get all custom sizes in srcset attribute

Pfff… I was four hours around this question and.. I got it. Is a very simple issue: original images are smaller than the custom size. So, custom sizes bigger than original images was not created for this images.

Get Image Having the ID [closed]

Put the below code in your functions.php and then you can use this [get_image_by_id id=”your-image-id”] shortcode to get the image add_shortcode( ‘get_image_by_id’, ‘the_dramatist_get_image_by_id’); function the_dramatist_get_image_by_id($atts) { return wp_get_attachment_image($atts[‘id’]); } Here “your-image-id” is numeric ID of the image. Hope that helps.

Else/If Statement to Display Photo Descriptions

How about like this: <div style=”position: relative”> <?php the_post_thumbnail(‘large’); $imagedesc = get_post(get_post_thumbnail_id())->post_content; if(!empty($imagedesc)) { echo ‘<span style=”position:absolute; bottom:9px; right:0; color:#FFF; background:rgba(0,0,0,0.8); padding:4px 6px; font-size:0.7em”>’; echo $imagedesc; echo ‘</span>’; } ?> </div>

Make image full width

Use the following CSS to target only the banner image on single posts: body.sinlge .size-banner-image { width:100%; } This will only work if your <div class=”container”> element is not restricted in its width, else the banner will only stretch to the container width.

Display an image based on field value

How about this? <?php $meta = get_post_meta( get_the_ID(), ‘region’, true ); if ($meta == ‘NA’) { ?> <img src=”https://www.esrnetwork.com/wp-content/uploads/2016/12/NA.png” width=”25″ height=”25″/> <?php } elseif ($meta == ‘EU’) { ?> <img src=”https://www.esrnetwork.com/wp-content/uploads/2016/12/EU.png” width=”25″ height=”25″/> <?php } else { } ?>

Error uploading images in wordpress

It’s usually a permissions error. We used to have these issues on our older servers. As a general rule for file permissions, you should never allow a folder to be “777” (Read/Write/Execute), but the uploads folder on this server, unfortunately, might need it. If you don’t know what I’m talking about, please take a read … Read more

Images Uploaded saving onto older/previous year folders

You should check yourself what you get when you execute wp_upload_dir. Typically you run this code: $d = wp_upload_dir(); print_r( $d ); wp_die(); And the reply needs to be like this in 2017/01 Array ( [path] => /var/www/html/test100.com/wp-content/uploads/2017/01 [url] => http://test100.com/wp-content/uploads/2017/01 [subdir] => /2017/01 [basedir] => /var/www/html/test100.com/wp-content/uploads [baseurl] => http://test100.com/wp-content/uploads [error] => ) You will … Read more

Speed Up Website With High Resolution Images

Thanks. i found a way to fix it. I created two sets of image, and placed them on different servers, CDN to be precise. I had a small sized image, to display in the list of all product catalog, and i had a large image display, for the each product information. Thanks for your comment.