wp_get_attachment_image_src always returns full-sized image
I think this code will help you: $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), ‘full’, false, ” ); echo ‘<img src=”‘.$src[0].'”>’;
I think this code will help you: $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), ‘full’, false, ” ); echo ‘<img src=”‘.$src[0].'”>’;
Research The question Filter For Featured Image lead to this answer: How to hook update_post_meta and delete_post_meta?. Coupled with the a fine global variable ($_wp_additional_image_sizes) revealed here: How to get a list of all the possible thumbnail sizes set within a theme, bring us to the code that catches the “Use as featured image” action … Read more
Gee, I keep solving my own problems all the time. Here’s how I solved it in the end. I discovered that add_image_size does not ignore the identical dimensions of the image size, but instead points the file name towards the same file in the uploads dir. Once I knew that, I could just save the … Read more
You can use the wp_generate_attachment_metadata filter: function wpse_183835_to_jpeg( $meta, $post_id ) { $sizes_to_convert = array( ‘thumbnail’, ); $path = dirname( get_attached_file( $post_id ) ); foreach ( $sizes_to_convert as $size ) { if ( ! empty( $meta[‘sizes’][ $size ] ) ) { $data = $meta[‘sizes’][ $size ]; if ( $data[‘mime-type’] === ‘image/png’ && is_file( $file = … Read more
You may want to look at the plugin Regenerate Thumbnails by Viper007Bond. Basically, this is how to do it: function regenerateThumbnails() { $images = $wpdb->get_results( “SELECT ID FROM $wpdb->posts WHERE post_type=”attachment” AND post_mime_type LIKE ‘image/%'” ); foreach ( $images as $image ) { $id = $image->ID; $fullsizepath = get_attached_file( $id ); if ( false === … Read more
A lot of the time the reason it isn’t working because you haven’t regenerated the thumbnails for all your images. If you have changed the dimensions of your images you will need to regenerate your thumbnails using this plugin: http://wordpress.org/extend/plugins/regenerate-thumbnails/
if you are referring to the ‘page for posts’, then try (only relevant section of your code shown): if (is_home() && get_option(‘page_for_posts’) ) { $img = wp_get_attachment_image_src(get_post_thumbnail_id(get_option(‘page_for_posts’)),’full’); $featured_image = $img[0]; } else {
$Featured_image = $wpdb->get_results(” SELECT p.* FROM net_5_postmeta AS pm INNER JOIN net_5_posts AS p ON pm.meta_value=p.ID WHERE pm.post_id = $da_id AND pm.meta_key = ‘_thumbnail_id’ ORDER BY p.post_date DESC LIMIT 15 “,’ARRAY_A’);
It is necessary to set an alt value for all of your images, in case a browser can not load the image or the visitor is using screen reader. You have two options. Either use the featured image’s caption (which can some times be blank) or use the post’s title as alt. You can get … Read more
I haven’t had time to test this but this looks like it should work for you. add_action(‘do_meta_boxes’, ‘remove_thumbnail_box’); function remove_thumbnail_box() { remove_meta_box( ‘postimagediv’,’post’,’side’ ); } Check this for more info. Edit: The main change here is that you need to attach the function to do_meta_boxes instead of admin_menu