Image Upload from URL

you can write a php script, or make your own plugin of this code here, i used it in one of my projects where i had to import a large number of images. first, get the image, and store it in your upload-directory: $uploaddir = wp_upload_dir(); $uploadfile = $uploaddir[‘path’] . “https://wordpress.stackexchange.com/” . $filename; $contents= file_get_contents(‘http://mydomain.com/folder/image.jpg’); … Read more

WordPress Theme Preview Image

There is no automatic preview. You need to create the screenshot yourself and place it in the theme/child theme folder named screenshot.png The recommended image size (currently) is 1200px wide by 900px tall, however the screenshot will only be shown as 387×290. It is over-sized to allow for high-resolution viewing on HiDPI displays. Note that … Read more

Filter to remove image dimension attributes?

Thanks all! The image_send_to_editor filter was the one I was looking for… thanks @t31os for pointing it out. Here’s my functions now. add_filter( ‘post_thumbnail_html’, ‘remove_thumbnail_dimensions’, 10 ); add_filter( ‘image_send_to_editor’, ‘remove_thumbnail_dimensions’, 10 ); function remove_thumbnail_dimensions( $html ) { $html = preg_replace( ‘/(width|height)=\”\d*\”\s/’, “”, $html ); return $html; } This removes inline dimension attributes from images retrieved … Read more

How To Retrieve An Image Attachment’s Alt Text?

I recently did some research for a client project recently so lo-and-behold I get to use it here! After the text you’ll see a categorized list of most (all?) of the image handling functions from within WordPress 3.0.1 (I grouped them in some semblance of order but don’t put too much credence in my categorization.) … Read more

How do I disable responsive images in WP 4.4?

Here are few things you could try to remove the responsive image support in 4.4: /** * Disable responsive image support (test!) */ // Clean the up the image from wp_get_attachment_image() add_filter( ‘wp_get_attachment_image_attributes’, function( $attr ) { if( isset( $attr[‘sizes’] ) ) unset( $attr[‘sizes’] ); if( isset( $attr[‘srcset’] ) ) unset( $attr[‘srcset’] ); return $attr; … Read more

Restricting users to view only media library items they have uploaded?

You could always filter the media list using a pre_get_posts filter that first determines the page, and the capabilities of the user, and sets the author parameter when certain conditions are met.. Example add_action(‘pre_get_posts’,’users_own_attachments’); function users_own_attachments( $wp_query_obj ) { global $current_user, $pagenow; $is_attachment_request = ($wp_query_obj->get(‘post_type’)==’attachment’); if( !$is_attachment_request ) return; if( !is_a( $current_user, ‘WP_User’) ) return; … Read more