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

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 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

show hide image script after 4 seconds [closed]

If you had for example, <img src=”https://wordpress.stackexchange.com/questions/228932/rdp_banner.jpg” id=”logoimage”> You could just do… add_action(‘init’,’checkvisitcookie’); function checkvisitcookie() { if (isset($_COOKIE[‘firsttimevisit’])) {return;} setCookie(‘firsttimevisit’,’1′,100*365*24*60*60); add_action(‘wp_footer’,’fadelogoout’); } function fadelogoout() { echo “<script> jQuery(document).ready(function() { setTimeout(function() { jQuery(‘#logoimage’).fadeOut(); }, 5000); }); </script>”; } Just to make it almost relevant to WordPress 😉

tech