You can try as like this, it may help you.
function filter_image_send_to_editor( $html, $id, $caption, $title, $align, $url, $size, $alt ) {
if('your error statement') {
$html="<script>alert("Some Error Message")</script>";
} else {
//your continue code
}
return $html;
};
// add the filter
add_filter( 'image_send_to_editor', 'filter_image_send_to_editor', 10, 8 );
More Info Regarding image_send_to_editor Filter : http://hookr.io/filters/image_send_to_editor/
Related Posts:
- show hide image script after 4 seconds [closed]
- Filter to remove image dimension attributes?
- Set default image link target in Gutenberg image block
- Change WordPress image URLs via filter
- Always use for post images
- Change html structure of all img tags in WordPress
- Default Image Link Removal
- Remove title attribute from images
- hook into completed image upload filter
- Graphing libraries for WordPress [closed]
- Need help building a filter to edit the output of “image_send_to_editor”
- Filter Media Library by author or post_parent
- Preview Image Path in Admin Section
- How to display a shortcode caption somewhere other than the_content
- Alter image output in content
- How can I remove the image attachment ALT field?
- add data-attribute to all images inside the_content()
- Filter to modify post_title after image upload?
- Change html structure of all img tags in WordPress
- Disable wordpress image sizes generation
- Extend core block attributes in post content
- 3.5 media.editor: what is the event listener for choosing an image?
- What’s the proper way to use the get_image_tag filter?
- Can I the caption shortcode to set caption to a data attribute, and with the image’s alignment intact?
- JavaScript and images files are not recognized
- How to get image ID to use inside wp_read_image_metadata()?
- Is there any action/filter hook to use when an image gets edited in the editor?
- How to create ‘Local’ filters for WordPress srcset sizes in template parts?
- Update an image block style programatically
- How to add custom classes to figure element only if image has caption?
- Change align classes for images
- How to filter the image embed code based on link type
- Add custom text in the media library image meta area
- WP 5.3 Removing Default WordPress Image Sizes
- Redirect to another page using contact form 7? [closed]
- Filter for post_thumbnail: link to small src and add data-attribute [duplicate]
- Howto use WP built in Thickbox for images?
- Remove Image Sizes in Media Settings Page
- How can I use wp_save_image_editor_file filter?
- How to stop WordPress from completely overriding my tags in my templates?
- Is it possible to enable the ‘Link To’ field under ‘Attachment Display Settings’ for a Featured Image?
- Prevent WP from wrapping html in caption shortcode after ‘image_send_editor’ filter is applied
- How can I change the to for lazyload wp smilies
- Image modification
- How to display a warning when an uploaded image is too small?
- How to change an image source when rendering on frontend?
- How to change Gallery image url in product page ? In function.php?
- Landing Page with HTML CSS JS and Images on wordpress
- How to get title of images in post content
- How to generate alt attributes with php / filters?
- Built-in image lazy loading: Does it come with a polyfill for older browsers?
- Images names not inserting in WordPress Database from Dynamic Add / Remove fields
- How to trigger “wp_handle_upload_prefilter” filter when uploading an image programatically?
- WordPress Javascript displaying an image Question
- Dinamically modifying attributes of images on posts
- How to attach post ID to image links in WordPress tinymce editor
- Display images from JS?
- image_send_to_editor filter – Unwanted paragraphs and line breaks
- How might one programmatically set the link for all images in all posts?
- Image filter works on attachement pages but not posts. I can’t get the image ID
- Surround uploaded image link with div
- Removing image dimensions from `the_content`
- Rename uploads filenames to POST-ID on upload
- 3.5.x Theme Customize: Handling Custom Control Requests
- Script not working in WordPress [duplicate]
- I tried to move the featured image below the paragraphs but now it is displaying twice
- How to add a link to media file for every image inserted in content?
- Replace image with its alt text?
- Get field added via attachment_fields_to_edit filter in Gutenberg
- Neither intermediate_image_sizes_advanced or intermediate_image_sizes filter is firing
- ‘Add Media’ to post – filter images
- ‘apply_filters’ is breaking some shortcodes/HTML but not all
- how to get original image using wp_get_attachment_image_src
- Hide custom image sizes from media library
- Removing default image size list in Media Box
- “There has been an error cropping your image” when cropping image
- How can you upload an image from within a settings page?
- Get an image from url in front end submission form
- Exclude featured image from gallery in wp-admin
- Customizing the attachement page to show rest of all images in a gallery from post
- Importing images results to wrong folder structure
- WP keeps looking up post thumbnail on https even though wp-config says http
- How to post a mosaic of an image gallery instead of the entire gallery inside a post’ [closed]
- Creating a post image to show in a gallery
- Replace post/page titles with an image in WordPress
- What happened to the media manger?
- image_resize() with blank space [closed]
- Re-ordering images in existing post in wordpress 3.6.1
- Change Image folder Locations
- “HTTP Error” or Network Error (tcp_error) when uploading image
- Optimising uploads folder then re-uploading?
- Add images to my theme with html
- The image keep redirect to my previous URL after I moving my site
- Define Folder to save Images
- adding images to wordpress pagination?
- Custom filename when pasting an image from clipboard
- How to return responsive images from a sanitize_callback?
- How to disable Right Click on a image? [closed]
- Convert all img tags into amp-img in wordpress content area
- [Solved]: Extend the list view in gutenberg editor?