It’s the image_send_to_editor filter:
if(is_admin()){
add_filter('image_send_to_editor', 'wrap_my_div', 10, 8);
function wrap_my_div($html, $id, $caption, $title, $align, $url, $size, $alt){
return '<div class="mydiv" id="mydiv-'.$id.'">'.$html.'</div>';
}
}
For existing images/posts you can try the regex in the function below
Related Posts:
- Importing media medium setting image gallery / image attachments
- problem in uploading attachment to custom directory
- Personalized Gallery what are my options?
- Custom image sizes ignored in WP 3.5
- How does WP media uploader create the 3 different sized images, and how can I duplicate it
- Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
- Rename UPLOADS folder with custom WP_CONTENT_DIR
- Disable image attachment links
- Why doesn’t WP_Image_Editor save images using the Filesystem API?
- How to move wp-content (or uploads) outside of the WordPress directory
- Limit Media Library to Given Folder
- Is there a plugin to make attaching images easier?
- using upload image with media_handle_upload .. but !
- Get attachment ID of author_meta image – Attachment Metadata
- Managing Images for a WordPress Blog: Picasa or Flickr?
- Automatic image renaming based on title
- Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?
- How do i upload an image and return the image id?
- media_handle_upload weird thing
- Looking to display non-image files in Gallery with logo specific to file type
- Get the post attached to a image attachment
- How to upload image without post ID using the new media uploader?
- Custom image size not selectable in uploader
- Rename attachments during upload
- How to add a rel attribute to images that contains their categories?
- Add suffix to filename of uploaded images
- Retrieving and Storing Images Linked from Other Domains on Local Server?
- sanitize attachment filename
- Extract & Display the REAL first image attached to a post – extend the_post_thumbnail()
- What’s the best “insert all images” plugin?
- Add filename to attachment page url
- How to re-arrange media uploaded using : media_handle_upload() as per year / month
- How to stop unlink images when remove a site or user
- Hide upload image fields for the different media upload popups
- Removing width and height attributes from wp-get-attachment
- Insert attachment ID in custom field from media uploader
- Adding width and height to wp_get_attachment_image_src
- media_sideload_image with rewritten urls?
- Is there a way to dynamically get to your uploads folder?
- Custom attachments styling in post view
- Add a InfoBox in the media upload window
- Using Fullscreenr with a wordpress blog – weird bug
- Create custom fields as image uploads [duplicate]
- Get Image from Media Library with the Title
- wp_generate_attachment_metadata is creating an empty array
- Prevent Delete Attachment by URL or When Submit
- Auto delete attachments that are older than x days
- Using custom image resizing script in a page
- wp_upload_bits Upload Specific Sizes Only
- Background image not appearing
- WordPress media uploader – upload tabs not hiding
- custom upload directory only for plugin uploads
- Redirect to another page using contact form 7? [closed]
- Does wp_get_attachment_image_src also work with non-image files?
- Best way to allow overwriting images shipped with the plugin?
- NextGEN Gallery – open all images on page in fancybox [closed]
- Featured Image If Else Condition
- Get images attached to a specific page
- WordPress Creates Unused (Unregistered) Image Sizes
- If custom image header does not exist display text header
- Upload attachment from external site
- How to query details of images in gallery that is attached to a post
- Is there a possiblity to replace profile image gravatar with custom user images
- Media Upload not working after hiding some elements from functions.php
- Custom theme – how to link the image without posting it
- Trying to set specific image dimensions and crop with ACF
- WP_Query: attachment image in “full” size?
- Attach File Funcion for Common people
- Customizing the gallery of the post correctly
- Transferring theme and imported post attachments
- Is there any way to modify images from a theme using the web interface?
- adding fade on mouseover to images
- Lightbox not showing image caption
- the temporary save folder is wrong
- POST 429 Error when trying to place more than 20 images into post at once
- wp_delete_attachment doesn’t delete image files / doesn’t work
- How to add the option to choose between sizes for featured image within post editor?
- How to disable post-thumbnail from generation?
- Altered Media Library URLs
- Bio comes up when the visitor clicks on a picture
- Adding images to anchors in the list created and fetched with wp_nav_menu
- Get “Image CSS Class” value from the Advanced Options section
- Is there a way to limit multi upload in media upload box?
- Troubles with code for upload a image
- Change default “Apply Changes To” radio option when editing images
- After I upload a file to library its name converted to dashes
- WP_Customize_Image_Control and selecting from library?
- Only User Upload image Http Error
- How to force attachment size for every post
- Upload button in metabox not working
- Adding thumbnails for non-image attachments
- featured images – custom links
- Get a different size of Image thumbnail while working with custom metabox
- Upload unnattached image from frontend
- WordPress uploads directory. Featured Images storage
- Is it possible to show related posts on WordPress attachment pages?
- Set custom banner image size with wp_customize
- How to get WordPress to resize images for srcset?
- How to search for replacement titles and contents, excluding image URLs
- Custom Search on media files PDF images pages posts