hide/protect original full-size images

I was looking for a way to do this and found this page… then I thought of putting this in a .htaccess file in the WordPress uploads folder and it works for me so far… any good? <FilesMatch “\.jpg$”> order allow,deny deny from all </FilesMatch> <FilesMatch “-[0-9]+x[0-9]+\.jpg$”> order allow,deny allow from all </FilesMatch> The first … Read more

upload image in a meta box

You may want to take a look at Steve Taylors plugin and his approach here Dominik “ocean90” Schilling – the author of the (new in 3.5) media library, has a GitHub repository where he shows off some demos. In short, you might not be able to implement a drag&drop style media uploader in a meta … Read more

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