Getting alt text of featured image

The alt text is stored as post meta on the attachment, and can be retrieved with get_post_meta() combined with get_post_thumbnail_id(): <?php echo get_post_meta( get_post_thumbnail_id(), ‘_wp_attachment_image_alt’, true ); ?> But if you just use the the_post_thumbnail() function then you don’t need to bother, the img tag will be output for you, with the alt text: <?php … Read more

Why can I not view image attachment pages?

From what you’ve described, it sounds like the theme doesn’t have an attachment.php template to handling displaying the actual attachment page. You check on the attachment page, by going to Appearance->Editor, and checking for an attachment.php; however, I believe that answer is incorrect. WordPress should default to displaying the image on the normal blog index … Read more

How to check if user is uploading/setting an image as a featured image?

Determining if an attachment actually is a featured image is easy: get_post_thumbnail_id( get_post() ); which is a convenience function around get_post_meta( get_post()->ID, ‘_thumbnail_id’, true ); It is a bit more complicated if you know nothing than the File name or Url. add_filter( ‘wp_handle_upload_prefilter’, function( $file ) { $url = wp_get_attachment_image_src( get_post_thumbnail_id( get_post() ), ‘post-thumbnail’ ); … Read more

Converting Attachment to Images?

Although it shouldn’t change based on your theme, this may be an issue caused by how this new theme handles images. As of WordPress 3.5, when you add a media object such as an image, there’s a sidebar that appears on the right. Underneath the “Attachment Details” (preview, title, caption, etc.) there’s a section called … Read more

Images in upload folder with hexadecimal names

Testing the plugin provided in this Answer, I just saw that media_handle_sideload generates exactly this pattern, jpeg extension as well (instead of jpg). Following its path through the core, it seems that only the filter wp_handle_upload could be used for dealing with that. But a brief research shows an interesting use of wp_handle_upload_prefilter: Rename files … Read more

Change code to display image attachment page

As pointed in the other answer, you should not have prettyPhoto part The link should be changed to utilize the function get_attachment_link Basically change this line in your code $link = ‘<a href=”‘.get_attachment_link($id).'”>’.wp_get_attachment_image($id, $size, false).'</a>’;