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

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

Creating a rotating header /image slider using theme customization

We can do that! First, you’ll need to add a custom section on the Theme Customizer, containing all the image uploads (we’ll use 3 for this example): add_action( ‘customize_register’, ‘themename_customize_register’ ); function themename_customize_register($wp_customize) { $wp_customize->add_section( ‘slides’, array( ‘title’ => ‘Slides’, ‘priority’ => 25, ) ); $wp_customize->add_setting( ‘first_slide’, array( ‘default’ => ”, ) ); $wp_customize->add_control( new … Read more

Get attachment ID of author_meta image – Attachment Metadata

I suggest you to use the more newer media manager dialog; WordPress will hanlde all the image upload stuff, including generating intermediate sizes and attachement metadata. Here a working example (it is a quick example built from a previous code, it may needs some tweaks to be used on production): add_action( ‘admin_enqueue_scripts’, ‘load_wp_media_files’ ); function … Read more

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