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?
- What’s the proper way to find and remove duplicate images from posts and the media library?
- Mixed content warnings after changing site adress from HTTP to HTTPS
- Insert an image into a post by API
- Use Media Library to manage galleries like Nextgen (with folders, albums, collections, tags, categories, terms…)
- Slider image issue in wordpress
- Retrieving images from a NextGEN gallery
- Query for recent images across multiple posts
- Get image alt attribute just by image URL
- get_children() not working properly – Only on one post?
- Warning: getimagesize() [function.getimagesize]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 [closed]
- Output random (custom) image size
- WordPress crops images differently on retina screens?
- Exclude images from “inserted into post” when trying to get attachments
- Move Image Captions Inside Link ( tag) if Added
- Sharing images to social media – issue with aspect ratio
- Facebook og:image issues after https change [closed]
- Does WP create multiple images?
- Mass crop images: Landscape images -> Portrait images
- Change image name during uploading sequentially
- How to redirect homepage to actual URL?
- How to disable thumbnail filter for a specific template part or image size?
- Cropped image file size larger than original, is it normal?
- Using mysql to replace img src?
- caption shortcode inserts blank paragraph
- Can I achieve this with WordPress?
- SQL: How to find all attachments that are not used in any posts/pages/custom_post_types
- I would like to set a FULL SCREEN background image to all my pages (same way it is on my home page)
- Enlarge Featured WordPress Images
- stop wordpress from resizing feature gif images
- Responsive images in Bootstrap 4 slider
- How can I add an “Attach image to this post/page” link on the Add Media lightbox?
- An image on my site is showing as the wrong image [closed]
- Orientation of featured image in post?