You could try with
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) {
if( isset($caption) && $caption )
return $html;
else
return '<div class="mydiv" id="mydiv-'.$id.'">'.$html.'</div>';
}
}
Related Posts:
- Get Image Description
- How to have different captions for same image, for galleries?
- Featured image shortcode
- How to wrap WordPress image captions inside H2, H3 tags?
- Is there a way to define a default caption to all uploaded images
- How to add a link in a image’s caption?
- Alter media caption/description conflict in WordPress?
- How to display a shortcode caption somewhere other than the_content
- Caption in Page adding unwanted 10px to width
- Adjust image caption within visal editor
- Drag images with caption in WP editor
- Different captions for the same image in multiple galleries. Edit Image in Gallery locally
- Include captions
- HTML tags in WordPress image caption
- Add attribute to caption shortcode from custom attachment field
- Removing height and width from images with a caption
- Include caption underneath post images
- Turn off image captions in gallery view?
- Move Image Captions Inside Link ( tag) if Added
- How to add custom classes to figure element only if image has caption?
- Replace image caption with its title and description
- Omit image captions from get_the_content()
- Random home page background images with caption text
- How to edit caption for images and exclude it from excerption query?
- Place image caption outside of figure tag (Gutenburg Image Markup)
- How to join Caption AND Description Meta Fields as one combined-caption in Image Block
- how automatically show the image title before the image caption/description in a wordpress gallery?
- How to Display Image Caption but Not Alt Text
- How to auto add image caption from image alt?
- Is there a way to create referable automatic numbering in image captions?
- Displaying “alt” attribute text as captions?
- page displaying media caption shortcodes
- How to add a credit line to a photo caption
- remove or update add_image_size
- get the attachement url for the medium sized image
- Is there a simple way to just insert a link to an image (without inserting an image)?
- Watermarking Images with WordPress with WP_Image_Editor
- Get attachment ID of author_meta image – Attachment Metadata
- Black and White thumbnails
- Alter image output in content
- How can I remove the image attachment ALT field?
- Open the attachment details modal
- Download button for Featured Image in every post – automatically
- Change html structure of all img tags in WordPress
- Get a list of all image sizes that match aspect ratio of original one
- Randomly add a ‘ul’ list of images
- Thumbnails are bigger in size than the original image
- Get an image’s alt text in a shortcode using the image URL
- Image resize depending on orientation?
- Character Limit w/ Excerpt removes Images Why?
- Featured images not displaying at full resolution
- Check if the image exists in WordPress media library
- Faster way to put images into a blog post by using Add Media dialog
- Retrieve an array of image URLs that belong to a gallery
- Images uploaded to the media library has strange colors. However, in the edit screen the color is ok
- wordpress post pagination with image buttons?
- How can I change get_the_post_thumbnail to make 100% width image?
- Native gallery sorting is ignored
- Disable lazy loading on specific images
- Custom responsive ‘featured image’ sizes
- removing the featured image from the post
- Dynamic image crop in WP 3.0+?
- What can i do add title to ‘large’ image?
- How to set minimum required size for featured image?
- Whats causing image quality to be degraded?
- Exclude image url from search query
- Inserting image into post with different image size
- WordPress Resize Image and show as thumb in post
- Resize uploaded images [duplicate]
- Image “description” and SEO within WP
- Why can’t I gain access to my homepage images?
- Family collaboration to identify ancestors on pictures
- How to change Gallery image url in product page ? In function.php?
- Display image of child element in wordpress
- How do you obtain a list of all image file names on a wordpress website for replacement?
- Form File Upload Field generates multiple copies of Image Files (different sizes): Is this a WP feature or is this being done by the Plugin
- Responsive header image
- Text Wrapping in Editor not Matching Website View
- Duplicate images on upload
- Redirect when user clicks on an image
- JPG Image extension not inserting into Custom table of wp
- wp_get_attachment_image_attributes not working
- Using WP 4.9.6 and big trouble showing images
- How to link to img src using HTML email template in WordPress
- How to add an image below the header on homepage
- List sub pages with custom field content converting image ID to URL
- Does the title and description attribute of images ever get shown?
- Automatically set full size for all my images in all my post and page?
- SVG files and wordpress
- Different image margins on different pages CSS [closed]
- Small image resizing for big! Alternative to timthumb
- Show custom image size smaller in editor
- add titles to images in ad media in pages and posts
- Setting name of attachment URL
- Show title when inserting single images
- Editing Featured Image Display When Creating Post
- How can I make image linking to attachment page (rather than a direct link)?
- How do I change a Themes Header Image?
- Blurry Images WordPress 5.8.1
- Profile Image displaying on Wrong side of WordPress Navigation Menu