Try this:
$caption_info = array();
add_filter( 'img_caption_shortcode', 'capture_caption', 10, 3 );
function capture_caption( $blank = '', $attr, $content ) {
global $caption_info;
$caption_info[] = array('attr' => $attr, 'content' => $content );
return ' ';
}
It will save info from all captions into global $caption_info
variable and suppress their display in content (space is returned because filter result is ignored if empty).
Related Posts:
- How to have different captions for same image, for galleries?
- Featured image shortcode
- Always use for post images
- Can I the caption shortcode to set caption to a data attribute, and with the image’s alignment intact?
- Add attribute to caption shortcode from custom attachment field
- Turn off image captions in gallery view?
- How to add custom classes to figure element only if image has caption?
- Prevent WP from wrapping html in caption shortcode after ‘image_send_editor’ filter is applied
- How to change an image source when rendering on frontend?
- Surround uploaded image link with div
- Get Image Description
- how to get original image using wp_get_attachment_image_src
- wp_get_attachment_image_src and server path
- How to find attachment by it’s name?
- Change WordPress image URLs via filter
- Change html structure of all img tags in WordPress
- How to wrap WordPress image captions inside H2, H3 tags?
- hook into completed image upload filter
- Theme Customiser Image Control
- How can I hide media library images from general users?
- Associate an existing image with a post
- Need help building a filter to edit the output of “image_send_to_editor”
- Is there a way to define a default caption to all uploaded images
- Programatically creating image attachments from local URLs and setting featured image
- Preview Image Path in Admin Section
- How do i upload an image and return the image id?
- Get Attachment ID from URL [duplicate]
- How to remove title attribute from gallery links and images
- Get an image from url in front end submission form
- Alter image output in content
- How can I remove the image attachment ALT field?
- How to upload image without post ID using the new media uploader?
- How do I delete thousands of unattached images?
- Applying class to links around self hosted images embedded to posts/pages
- Get post embedded image caption
- Re-process Images
- Show prev and next post links for parent post of current image in attachment page?
- Pulling Post Image Attachments in WordPress 3.9
- Change html structure of all img tags in WordPress
- Link Featured Thumb to Attachment Page, If Possible
- Different captions for the same image in multiple galleries. Edit Image in Gallery locally
- Best way to programatically add “rel” attributes to page and post images
- Image still linked as attachment to page even though it has been deleted
- Disable wordpress image sizes generation
- Extend core block attributes in post content
- Why can I not view image attachment pages?
- Add a new data attribute in tag
- Link to full size image or attachment page in photo theme
- add the post as canonical for attachment page wordpress
- How to get image ID to use inside wp_read_image_metadata()?
- Is my code is right to make image shortcode
- Add an attribute to attachments
- Include caption underneath post images
- Pull images from the gallery
- How to create ‘Local’ filters for WordPress srcset sizes in template parts?
- Customizing the attachement page to show rest of all images in a gallery from post
- How to filter the image embed code based on link type
- wp_upload_bits Upload Specific Sizes Only
- Add custom text in the media library image meta area
- Rewrite all article pictures to link to file
- Don’t show images inserted into content
- WP 5.3 Removing Default WordPress Image Sizes
- Redirect to another page using contact form 7? [closed]
- wp get attachment image always gives me thumbnail
- Remove Image Sizes in Media Settings Page
- Load Gallery Images with Title on Homepage BX Slider
- Retrieve Image Attachments Getting Post Thumbnail Image First
- How can I use wp_save_image_editor_file filter?
- One picture belonging different galleries?
- Shortcode function doesnt work without caption
- WordPress Attachments with old images
- How to get image URL from media_sideload_image?
- How can I change the to for lazyload wp smilies
- Use full size images in a specific gallery
- Random Characters in the end of every image url in post
- Output posts attached images as thumbnails linked to full-size with lightbox class
- Can i have 2 separate Galleries on 2 separate pages each go to a DIFFERENT Attachment.php file?
- How to display a warning when an uploaded image is too small?
- How to change Gallery image url in product page ? In function.php?
- How to generate alt attributes with php / filters?
- Custom image size not displaying with wp_get_attachment_image()
- attachment_fields_to_save first parameter is null
- How to disable post-thumbnail from generation?
- js alert in add_filter function for image_send_to_editor
- Post Images are not showing up whenever I use shortCodes in my posts
- How to Make Only Images Connected to a Post Show? Not Entire Media Collection?
- WordPress Shortcode to display featured images only
- Displaying “alt” attribute text as captions?
- image_send_to_editor filter – Unwanted paragraphs and line breaks
- After I upload a file to library its name converted to dashes
- Gallery with shortcode not showing
- Extract url from next_image_link
- Setting name of attachment URL
- Lots of attachments is causing slow load
- Rename uploads filenames to POST-ID on upload
- Show title when inserting single images
- Wrap a post image with a div if it doesn’t have a caption
- How to access & display images from a post without textual content ( and vice versa) according to best wordpress practices
- How can I use an image from an external source without uploading it to the media library
- Remove one srcset entry from wp_get_attachment_image