3.5 media.editor: what is the event listener for choosing an image?

Found out that overriding some of the wp.media.editor objects methods is the best solution, because it allows you to customize the event handling, but will also preserve a lot of the backend processing and handling that WP has in place for processing images. I basically overrode wp.media.editor.send.attachment, wp.media.gallery.shortcode with my own methods, and wp.media.editor.remove, in … Read more

Why html tags are being appended to my pictures?

Sometimes, WordPress likes wrapping <img … tags with extra HTML. You could try something like as listed on http://css-tricks.com/snippets/wordpress/remove-paragraph-tags-from-around-images/. In your theme’s functions.php file, add the following lines of code near the top: function filter_ptags_on_images($content){ return preg_replace(‘/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU’, ‘\1\2\3’, $content); } add_filter(‘the_content’, ‘filter_ptags_on_images’);

How to get image extension from wp image editor object?

I tried using generate_filename yesterday but probably it was kind of late and I was trying and didnt manage to make it work, today I managed to workaround the problem without fetching the image another time like this: $save_path = WP_CONTENT_DIR . ‘/tmp/’ . $img_name . “-” . $nw . “x” . $nh; $wp_img->save($save_path); $img_name … Read more

Broken urls with http site and https wp-admin

My advice is to make the whole site https. Either add https to the settings -> wordpress address & settings -> site address or remove https if it appears in either of those inputs. For securing admin login panel only: easy method but doesn’t show secure icon. right result but more steps to consider method.

Different upload path per file type

Change upload directory for PDF Files seems to be a good stepping stone forward. Although untested, looking at the code my adaptation would be along the lines of… <?php add_filter(‘wp_handle_upload_prefilter’, ‘custom_media_library_pre_upload’); add_filter(‘wp_handle_upload’, ‘custom_media_library_post_upload’); function custom_media_library_pre_upload($file){ add_filter(‘upload_dir’, ‘custom_media_library_custom_upload_dir’); return $file; } function custom_media_library_post_upload($fileinfo){ remove_filter(‘upload_dir’, ‘custom_media_library_custom_upload_dir’); return $fileinfo; } function custom_media_library_custom_upload_dir($path){ $extension = substr(strrchr($_POST[‘name’],’.’),1); if ( !empty( … Read more

Automatically replace original uploaded image with large image size

Add this to the functions.php file in the theme folder. It replaces the original image with the large image set in settings. You might want to setup a new image format and use that as the new original size though. function replace_uploaded_image($image_data) { // if there is no large image : return if (!isset($image_data[‘sizes’][‘large’])) return … Read more

Responsive Images Resizing Images

The issue I was having was with some conflicting code I had in my functions file (see below). I usually use this code to remove width/height attributes from being hard-coded into the element in the content area. Removing these somehow appears to mess up the new responsive image implementation in WordPress though. As soon as … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)