Need help building a filter to edit the output of “image_send_to_editor”

Your best bet here would be to use jQuery to grab any link that links to an image and tell it to use fanceybox. jQuery(document).ready(function($){ $(‘a[href$=”jpg”], a[href$=”png”], a[href$=”jpeg”]’).fancybox(); }); If you want this to work just for your post content areas use this: $(‘.post-content a[href$=”jpg”], .post-content a[href$=”png”], .post-content a[href$=”jpeg”]’).fancybox(); You will need to replace .post-content … Read more

How can I attach images to a post from the media library?

This is not something that is currently supported in WordPress. There’s some discussion about it here: http://core.trac.wordpress.org/ticket/6820 One plugin which does enable this functionality is: http://skyphe.org/code/wordpress/file-gallery/ This plugin does a few extra things, but one option it provides is that after clicking “upload/insert” and going to the media library tab, you can tick check boxes … Read more

get images attached to post

It’s better to use get_children than get_posts. Here is a quick example that will work. This is in the form of a function that is defined in your plugin or in functions.php then use the function as a template tag. /** * Gets all images attached to a post * @return string */ function wpse_get_images() … Read more

Associate an existing image with a post

You can modify an existing media library image using wp_insert_attachment by setting the ID key in the parameter array. $attachment = array( ‘ID’ => $existing_library_attachment_id, ‘post_parent’ => $custom_post_id ); wp_insert_attachment( $attachment ); This will update the attachment post with ID $existing_library_attachment_id to have a post_parent value of $custom_post_id. However, the only thing this will affect … Read more

Add aditional class to get_avatar when showing image

I had this problem, too. Here’s the solution for version 4.7.3 if anyone comes across this. get_avatar( $id_or_email = get_the_author_meta( ‘user_email’ ), $size=”60″, $default, $alt, $args = array( ‘class’ => array( ‘d-block’, ‘mx-auto’ ) ) ); or shorter version get_avatar( get_the_author_meta( ‘user_email’ ), ’60’, $default, $alt, array( ‘class’ => array( ‘d-block’, ‘mx-auto’ ) ) ); … Read more

Fixing external image urls

Since the request is sending to the blogspot server, no .htaccess wont wont. You could filter your post content output: add_filter(‘the_content’, function($the_content) { return str_replace(‘/s400′,’/s1600′,$the_content); }); Or you could edit modify the database global $wpdb; $wpdb->query(“UPDATE $wpdb->posts SET `post_content` = REPLACE(`post_content`,’/s400′,’/s1600′);”); Or do it in mysql UPDATE wp_posts SET `post_content` = REPLACE(`post_content`,’/s400′,’/s1600’; assuming wp_posts is … Read more

Can WordPress resize BMP files?

No, wordpress can not resize BMP files. Beware that it does not make sense to use BMP files in a website because a broad number of webbrowsers is not able to display them. Filetypes that are supported by WordPress and which are widely supported by internet browsers are: GIF, JPG and PNG. Those formats are … Read more

Black and White thumbnails

You can use the php GD library which you most likely already have on your server since wordpresses uses it. You can filter the image using imagefilter specifically IMG_FILTER_GRAYSCALE and/or IMG_FILTER_CONTRAST. For example imagefilter($im, IMG_FILTER_GRAYSCALE); imagefilter($im, IMG_FILTER_CONTRAST, -100); The hover would have to been done in javascript. A much simpler solution would be to use … Read more