add_filter with specific thumb names
The class attribute contains the size in the format attachment-$size, you could do a check for a specific size like: if( strstr( $attr[‘class’], ‘thumb’ ) ): // size is attachment-thumb endif;
The class attribute contains the size in the format attachment-$size, you could do a check for a specific size like: if( strstr( $attr[‘class’], ‘thumb’ ) ): // size is attachment-thumb endif;
In your work.php code sample you are calling get_post_meta( $post->ID, ‘the_post_thumbnail’, true) This has nothing to do with WordPress post thumbnails and is looking for a custom field with the post meta key ‘the_post_thumbnail’ For more info see: get_post_thumbnail_id wp_get_attatchment_image_src Post Thumbnails To get the src url of the featured image attached to the post … Read more
I was trying to set the Core post-thumbnail. I found my issue. I was running the function: delete_post_meta($post_id, ‘_thumbnail_id’), before I would set_post_thumbnail($post_id,$thumb_id); Apparently even though the delete was in the code before it still caused it to delete it from the DB. Very strange… I had it in there as I was worried I … Read more
I would start by checking that everything is good with the image being saved to the CPT. Inside the loop… <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?> <?php echo $url ?> This will hopefully echo the image’s URL… if that is working then you probably have a problem with the loop conflicting with something else … Read more
Unless there’s some part of your problem I don’t grasp, what’s wrong with a simple mash-up of the two given snippets? <?php global $post; $urlbox = get_url_desc_box(); $post_thumb = get_the_post_thumbnail( $post->ID, ‘screenshot’ ); if( !empty( $urlbox[0] ) && !empty( $post_thumb ) ) { echo sprintf( ‘<a target=”_blank” href=”https://wordpress.stackexchange.com/questions/66759/%1$s”>%2$s</a>’, $urlbox[0], $post_thumb ); } ?> Edited: get_the_post_thumbnail … Read more
Seems to me you use a WordPress theme which uses some kind of php library to resize images. You should really use WordPress default add_image_size() and wp_get_attachment_image but if you were the one who created the theme you would already know that. There are 3 things you can do: find a new theme that is … Read more
You can add image sizes and cropping settings with the add_image_size() function. Call the declared name of your size at the frontend and you’ll have your desired size and crop. The image is stored as an id, you can pick whatever size you want with the the_post_thumbnail() function. PE: the_post_thumbnail(‘medium’); will show the featured image … Read more
I don’t think your code is the issue here. But there are a few caveats that you need to be aware of and account for. First off always keep in mind that when using add_image_size() that WordPress does not regenerate the images size if it was uploaded before you registered the new size. The newly … Read more
I’ll guess that admin_init is too early for remove_menu_page, the hook should be admin_menu.
All your issues could be solved with some MySQL queries. Regarding point #1: if you are using mod_rewrite then I recommend using absolute URLs for images in posts, if you are displaying full post content (including its images) on other pages – as you suggest. You can do a MySQL search/replace as follows: UPDATE wp_posts … Read more