Remove inline width from figure
SOLVED I’m using roots theme. So I open cleanup.php file and comment/remove this line: $attributes .= ‘ style=”width: ‘ . (esc_attr($attr[‘width’]) + 10) . ‘px”‘;
SOLVED I’m using roots theme. So I open cleanup.php file and comment/remove this line: $attributes .= ‘ style=”width: ‘ . (esc_attr($attr[‘width’]) + 10) . ‘px”‘;
st Note: // Prepare the code for safety $images = $wpdb->get_col( $wpdb->prepare( ” SELECT ID FROM %s WHERE post_type=”attachment” AND ID IN ( %s ) ORDER BY menu_order ASC “, $wpdb->posts, $meta ) ); nd Note: Look into what you already got: // Inside the foreach loop echo ‘<pre>’; var_dump( $att ); echo ‘<pre>’; rd … Read more
It will be interesting to see how the new evolving WP Gutenberg editor will handle shortcodes and embeds. If you use the shortcode for embedding, then a semi workaround, without UI support: where the custom desc attribute is supported with with this kind of wrapper: add_filter( ’embed_oembed_html’, function( $return, $url, $attr ) { if( ! … Read more
You can directly get an attachment’s meta data if you have it’s ID. The alt data for an attachment is stored in _wp_attachment_image_alt. So, you can use: $alt = get_post_meta( $attachment->ID, ‘_wp_attachment_image_alt’, true); To get the caption of an image, you can use wp_get_attachment_metadata(). $metadata = wp_get_attachment_metadata( $id ); $caption = $metadata[‘image_meta’][‘caption’]; EDIT Based on … Read more
The caption is stored in the image data. The only way to achieve what you require is to use multiple copies of the image and change the image data on each image. To better understand image data go ahead and download an image to your desktop then right click it, go to properties then the … Read more
Adapted from this answer Add this code to your functions.php file: add_action( ‘after_setup_theme’, ‘wpse_74735_replace_wp_caption_shortcode’ ); /** * Replace the default caption shortcode handler. * * @return void */ function wpse_74735_replace_wp_caption_shortcode() { remove_shortcode( ‘caption’, ‘img_caption_shortcode’ ); remove_shortcode( ‘wp_caption’, ‘img_caption_shortcode’ ); add_shortcode( ‘caption’, ‘wpse_74735_caption_shortcode’ ); add_shortcode( ‘wp_caption’, ‘wpse_74735_caption_shortcode’ ); } /** * Add the new class to … Read more
This is/was a known bug that should be fixed in WP >= 4.4 See this ticket for details: https://core.trac.wordpress.org/ticket/28003
Adjust image caption within visal editor
If I understood correctly, you are trying to add, to every image embedded in a post gallery, a custom rel attribute and a title attribute based on the attachment caption. Instead of parsing the content, you can try to modify the anchor that wraps the images using the ‘wp_get_attachment_link’ filter. <?php function wpse221533_add_caption_title_to_content_gallery_image_attachments( $markup, $id, … Read more
Get the attachment ID and convert to a post. From there the caption is stored on the post object. $thumb_img = get_post( get_post_thumbnail_id() ); // Get post by ID echo $thumb_img->post_excerpt; // Display Caption echo $thumb_img->post_content; // Display Description In your loop it would look like: <?php if($gallery) : ?> <?php foreach($gallery as $key => … Read more