All my inserted images gets a link to the full image even if it is already full size image

The following code will empty the Link URL field when Full Size button is clicked. And fill the same field with the File URL value when other buttons are clicked. Tested with WordPress 3.4.2. Drop the code in your theme’s functions.php file or create a simple plugin for it. add_action( ‘admin_head-media-upload-popup’, ‘wpse_41539_add_remove_image_url’ ); function wpse_41539_add_remove_image_url() … Read more

How to remove the whitespace in image name and save the new file

Use sanitize_file_name( $filename ). This function doesn’t just catch white space, it removes other special characters too: $special_chars = array( “?”, “[“, “]”, “https://wordpress.stackexchange.com/”, “\\”, “=”, “<“, “>”, “:”, “;”, “,”, “‘”, “\””, “&”, “$”, “#”, “*”, “(“, “)”, “|”, “~”, “`”, “!”, “{“, “}”, chr(0) ); Find the following line in the plugin’s code: … Read more

Check if page/post has any anchors that link to an image jpg/gif/png

This method has worked in the past for checking if a shortcode exists on a page. You will have to test it and see if it fires in time to enqueue the javascript> add_filter(‘the_posts’, ‘c3_image_check’); function c3_image_check($posts){ if (empty($posts)) return $posts; $img_found = false; foreach ($posts as $post) { if (stripos($post->post_content, ‘<img src=”https://wordpress.stackexchange.com/questions/53585/)) { $img_found … Read more

WP 3.4 has missing photo data

Having figured out the issue, I’d like to update this question. The issue stems from previous versions of WP not including the _wp_attached_file meta key when uploading media, which 3.4 now seems to require. Below is PHP code for looping through the database, verifying the presence of both the key and image file, then updating … Read more