Height and width attribute not setting by the_post_thumbnail

In the 2nd attribute of the_post_thumbnail() you can give additional attributes for the image. the_post_thumbnail( ‘postbox-thumb’, array( ‘width’ => 100, ‘height’ => 100 ) ) I’ve just checked it again the width and height are set in the latest WP Versions, so you might have just to update your WordPress installation.

How can I use wp_save_image_editor_file filter?

The filter inside ~/wp-admin/includes/image.edit.php looks like this: apply_filters(‘wp_save_image_editor_file’, null, $filename, $image, $mime_type, $post_id); So a callback would look like the following: add_filter( ‘wp_save_image_editor_file’, ‘wpse91038_saved_image_editor_file’, 10, 5 ); function wpse91038_saved_image_editor_file( $saved, $filename, $image, $mime_type, $post_id ) { var_dump( $saved ); var_dump( $filename ); var_dump( $image ); var_dump( $mime_type ); var_dump( $post_id ); return $saved; } Right … Read more

Retrieve Image Attachments Getting Post Thumbnail Image First

First, exclude the featured image (= post thumbnail) from the query, then set up the posts array as combination of the featured image and the other images. Put this directly below $args = … and above $attachments = …: if (has_post_thumbnail($post->ID)) { $featured_image = get_post_thumbnail_id($post->ID); $args[‘exclude’] = $featured_image; $attachments = array(get_post($featured_image)) + get_posts($args); } else

What can i do add title to ‘large’ image?

Check the Codex. the_post_thumbnail accepts two parameters, the second of which is $attr— “attributes”. the_post_thumbnail(‘full’,array(‘title’=>’yay! a title!’)); The Codex entry for the_post_thumbnail is not clear on what is and is not allowed as an “attribute” but it appears to depend on wp_get_attachment_image and by filters applied by that function. title does work though. I checked.

Dynamic image crop in WP 3.0+?

http://codex.wordpress.org/Class_Reference/WP_Image_Editor http://codex.wordpress.org/Function_Reference/wp_get_image_editor $image = wp_get_image_editor( ‘cool_image.jpg’ ); if ( ! is_wp_error( $image ) ) { $image->rotate( 90 ); $image->resize( 300, 300, true ); $image->save( ‘cool_image.jpg’ ); } Repalce cool_image.jpg with a variable holding the path to the image you want to edit. Not a copy and paste solution but should put u on the right … Read more

Create a post from every image in my media gallery

If you have the image in your media library you can just loop trough them and create post via wp_insert_post. function import_post_from_imgs() { $images = get_posts(‘post_type=attachment&post_status=inherit&posts_per_page=-1’); // just a minimal security check if ( ! current_user_can(‘publish_posts’) ) return; if ( ! empty($images) ) { foreach ( $images as $image) { // prevent duplicate if for … Read more