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 field added via attachment_fields_to_edit filter in Gutenberg
- Filter to remove image dimension attributes?
- Programmatically adding images to media library
- Programmatically get images by URL and save in uploads folder
- Get Image Description
- how to get original image using wp_get_attachment_image_src
- Can I attach image to post without adding it to post?
- Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
- 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
- Default Image Link Removal
- Remove title attribute from images
- How do I delete all generated images from my server except those currently used in posts
- Insert an image into a post by API
- Function to call the attachment image from post
- 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?
- Get attachment ID of author_meta image – Attachment Metadata
- 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
- Filter Media Library by author or post_parent
- Preview Image Path in Admin Section
- How to add a link in a image’s caption?
- How do i upload an image and return the image id?
- Get Attachment ID from URL [duplicate]
- Insert Images at Master Uniform Height
- Alter media caption/description conflict in WordPress?
- How to remove title attribute from gallery links and images
- Separate attachment images from post loop
- How can I make all gallery images to open in a new window?
- Caption in Page adding unwanted 10px to width
- copy attachment title to description and alt text
- Get an image from url in front end submission form
- Alter image output in content
- How can I remove the image attachment ALT field?
- Open the attachment details modal
- How to upload image without post ID using the new media uploader?
- How do I delete thousands of unattached images?
- add data-attribute to all images inside the_content()
- Allowing post attachments without allowing to insert in text
- Applying class to links around self hosted images embedded to posts/pages
- Get post embedded image caption
- Rename attachments during upload
- Filter to modify post_title after image upload?
- Regex to turn embedded images in to attachments
- Adjust image caption within visal editor
- Re-process Images
- Show prev and next post links for parent post of current image in attachment page?
- Drag images with caption in WP editor
- Pulling Post Image Attachments in WordPress 3.9
- Change html structure of all img tags in WordPress
- get attributes/part of the gallery shortcode
- Link Featured Thumb to Attachment Page, If Possible
- Different captions for the same image in multiple galleries. Edit Image in Gallery locally
- How do i reference the theme path in pages for images?
- Regenerate missing _wp_attachment_metadata
- Make alt text required when setting a featured image
- Include captions
- 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
- Editing built in Gallery shortcode to filter by categories
- Extend core block attributes in post content
- Display one random image, but only if landscape
- get_attachment_id() only get id of first attached image after post update
- Why can I not view image attachment pages?
- Is there a way to get attachment data?
- What’s the proper way to use the get_image_tag filter?
- How to change image url?
- Add a new data attribute in tag
- Custom page template to display all image attachments
- HTML tags in WordPress image caption
- Link to full size image or attachment page in photo theme
- get the image of the post
- add the post as canonical for attachment page wordpress
- Get an image’s alt text in a shortcode using the image URL
- How to get image ID to use inside wp_read_image_metadata()?
- Shortcode for a link and thumbnail
- media_sideload_image with rewritten urls?
- Is my code is right to make image shortcode
- Set Post Image Using Shortcode
- How to check if there is image title, caption, description?
- Add an attribute to attachments
- Removing height and width from images with a caption