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
- How to load only a certain type of image (functions.php)
- Remove tab on product for one category, keep but change image for another
- ‘apply_filters’ is breaking some shortcodes/HTML but not all
- Is possible to open directly the core WP image editor on a modal?
- Edit image results in copies of file being created
- Images in Media aren’t showing, not broken
- How to replace images?
- Images not displayed when moving site to local
- wp_upload_bits Upload Specific Sizes Only
- Fixing image names for a site being restored
- Upload Image using wp_insert_attachment and file url don’t have file extension
- Replace image caption with its title and description
- Problem Cropping Images From WP Customizer
- Retain the original name of the image on resize
- Custom thumbnail size of image when uploaded
- How To Get The File Extension Of Images Having Different Extensions In A Directory?
- Show image EXIF info
- using media_sideload_image with a file from theme directory
- Image increasing kb on resize
- I want to use the GD image editor for just one function then switch back to ImageMagick
- WordPress 4.1 header image problem
- force feed readers to pick atom version
- wp_customize_image_control deprecated add_tab alternative
- Images uploaded to the media library has strange colors. However, in the edit screen the color is ok
- attach image from library to post with wp_insert_attachment
- Change wp-content/uploads to uploads/%postname%/%image%
- wp_get_attachment_image_src() returning incorrect width and height [duplicate]
- Is there any way to Integrate WordPress with Imgur for Image Hosting
- GoDaddy Number of Image Files Per Directory Exceeded