The best answer I had was to add a   in the function callback html at the end of the section tag. This forced the curser out of section wrapper in the WYSIWIG of WordPress. It’s not the perfect fix but it worked.
function html5_insert_image($html, $id, $caption, $title, $alt, $align, $url) {
$url = wp_get_attachment_url($id);
$html5 = "<section class="js-simple-lightbox">";
$html5 .= "<figure class="cbp-item">";
$html5 .= "<a class="cbp-lightbox" data-title="$title" href="https://wordpress.stackexchange.com/questions/206966/$url">";
$html5 .= "<img class="img-responsive" src="https://wordpress.stackexchange.com/questions/206966/$url" alt="$alt" width="100%" />";
$html5 .="</a>";
$html5 .= "</figure>";
$html5 .= "</section> ";
return $html5;
}
add_filter( 'image_send_to_editor', 'html5_insert_image', 10, 9 );
Related Posts:
- wp-cli post create & media import issues
- Replace image attributes for lazyload plugin (data-src)
- How do I detach images from posts?
- Unattaching images from a post
- How to wrap every image in a post with a div?
- upload featured image from front end using wordpress add media button
- Retrieving and Storing Images Linked from Other Domains on Local Server?
- how to replace embedded “full” sized images within a post with the “large” ones
- Errors when uploading images in WP 3.5
- Remove Featured Image & All Media Uploaded to the Post
- How to allow multiple thumbnail upload for Posts?
- How to get all inline images in post content? [duplicate]
- Inserting Media to WordPress Posts
- Site/Post preview is not working on all social media
- unable to write to the database while uploading images
- Modified core/image rendering not showing in posts – only on pages
- Post images are not displayed in media library
- WordPress Media URLs?
- How would I attach media/images to a post based on a ID stored in a each post’s custom field
- Broken images after importing posts and opening in Gutenberg
- Optimize blog that serves hundred of images and videos
- Remove Categories / Tags From Admin Menu
- Delete the original big size image after upload and leave only 3 images crunched by media gallery
- media_handle_upload for local files?
- Is this the best (and only) option to style CSS for a given post type?
- Sort post by attributes ‘order’
- How to change the layout and styling of posts according to their category in WordPress?
- Pagination not working on Custom Page Template
- Display custom post types by date field
- How to hook a function only when I need to delete permanently a post?
- What Can I Use To Add A Custom Button Between Publish button and Move To Trash?
- user contributed content as custom post types
- Is there any WordPress alternative to Book module of Drupal?
- How to get only text from wordpress post content?
- How to start with post number x?
- Get all images out of the posts content
- Best way of deletion of old posts [closed]
- Sidebar links for different pages
- Deleted category by mistake, all posts now have categorized category. Can i revert that?
- Delete post by giving its link
- How to make classes for posts?
- Set size for attachments
- Get Image from Media Library with the Title
- I have a site where attachments in the wp_posts table have guid values of guid, how did this happen?
- Getting Custom Post Loop to display in Bootstrap 3 column grid
- Turn On Comments On Custom Post Types in Directory Theme
- ERROR: Your feed is invalid (after update WP4.7) in custom types
- Automatically add date to the auto generation of post slug
- Duplicate Custom Post Type and Taxonomy Slug
- How could I change my Permalink from blog to custom structure? [closed]
- Automatically attach image to post if they have the same title
- WP Admin register taxonomy and post type performance
- How to get the last selected media alignment setting?
- WordPress Multisite – Create Default Post and New Category On New Site Install
- Show only posts with images and a fixed amount of posts
- If statement to check if post has image
- What are the benefits of setting a “featured image” for a WP blog post?
- Format latest/newest post differently
- relating business and products with custom taxonomy?
- WordPress Query Posts From Category Post on Static Page
- Edit multiple custom post types while saving a new or edited post
- Create a custom posts page
- add external project to web site wordpress on production
- get_children returns older images
- How to display post title inside thumbnail?
- register_post_type permalink
- How to remove text and retain in caption image using the_content function
- Change default post style to columns
- Custom Post Type, post-formats associated to custom post type > 404 archives
- Delete post from admin but not from database
- Only show featured image on exerpt and exclude images in post
- how can display a post on home screen without images
- Custom Select Query – Selecting the Year?
- Deleting old posts
- How To Use Custom Tax of a Post Type
- What would causes search to return incorrect results?
- search form for custom fields
- Pinterest button shows image options from different posts
- Tag for custom post type
- Blog images not showing on homepage
- Manual Scheduler For Custom Post Type
- Dev and prod on the same database- dev version active for IOS
- How to delete/customize imported demo content from a theme or add my own?
- Integrate video and iframe in a post type gallery
- Unable to delete images in Media Library
- how to create other sizes of original image in one go wordpress uploads
- single- and archive- templates not being applied to custom post types, not even after flushing permalinks
- How to show content of specific item on the same page?
- SQL query to remove first image in all posts
- Bulk Attach Or Insert Media To Post Without Opening Post Editor
- How to add audio media in a post?
- Add default content to post (for specific category)
- First Custom Post Custom Fields Empty After New Custom Post
- Assign custom class to post content images
- Display one post randomly from category on home page
- How to have more post in a page than in your home page
- Only show posts belonging to multiple cateogries at same time
- Dynamic Menu Item
- Inserting Media on New Post But Hides Previous Uploads for Editor/Contributor
- I have a website issue I am trying to resolve