hook into completed image upload filter

WordPress’ media handling strikes me as scattered and inconsistent. I say that only to say that I can’t promise this will work in all cases. However, I think I’d use the add_attachment hook from wp_insert_attachment. You will get a post ID, so you will have to … retrieve the image src with wp_get_attachment_imge_src, probably, retrieve … Read more

How to wrap WordPress image captions inside H2, H3 tags?

You can hook into the filter img_caption_shortcode and replace the whole captioned image. Here I’ve copied the caption shortcode function from WP4.5, left the version used if your theme declares HTML5 support as it is (using figcaption) and modified the non-HTML5 version to use h2. function wpse_233354_img_caption_shortcode( $empty, $attr, $content = null ) { // … Read more

Insert an image into a post by API

You can set the uploaded image as the post thumbnail via, update_post_meta($post_id,’_thumbnail_id’,$attach_id); Example… if ($_FILES) { foreach ($_FILES as $file => $array) { if ($_FILES[$file][‘error’] !== UPLOAD_ERR_OK) { return “upload error : ” . $_FILES[$file][‘error’]; } $attach_id = media_handle_upload( $file, $post_id ); } } update_post_meta($post_id,’_thumbnail_id’,$attach_id); If you are uploading an array of images, then you … Read more

Which action hook can I use when a featured image has been selected

The set_post_thumbnail function uses the metadata functions to set the featured image. You have two actions to hook into that process: EDIT: The action hooks are now defined different Thanks @dalbaeb! update_postmeta, before the data is written into the database. Previously update_post_meta updated_postmeta, after the data is written into the database. Previously updated_post_meta SECOND EDIT: … Read more

add_image_size() zoom-crop

Currently, WordPress core image handling/thumbnail creation does not perform zoom-crop. If you need an intermediate image size to be created explicitly, you will need to ensure that you upload an image with equal or larger dimensions as the intermediate image size.

replace wp_get_attachment_image with my own function

There is a filter, wp_get_attachment_image_attributes, for the image attributes– a well designed one too. function alter_att_attributes_wpse_102079($attr) { $attr[‘data-src’] = $attr[‘src’]; return $attr; } add_filter( ‘wp_get_attachment_image_attributes’, ‘alter_att_attributes_wpse_102079’); That will add the data-src attribute. That looks like what you need. You could add more attributes, or alter the existing onese, if you need.

Remove title attribute from images

I would strongly discourage this. A better, more sustainable practice would be to educate your clients on the value of the title attribute and teach them how to use it properly. Simply removing it is putting a bandage on the symptom, not combating the disease. However, if you do want to remove the attribute anyway, … Read more

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