Skip to content

Instantly share code, notes, and snippets.

Avatar
👓
Focusing

McPeanut Kotty beeriz

👓
Focusing
View GitHub Profile
@beeriz
beeriz / gist:e194e40d47a90a0720c8cfd599256750
Last active Apr 6, 2018 — forked from johndugan/gist:4359828
WordPress: remove inline width from figure
View gist:e194e40d47a90a0720c8cfd599256750
<?php
add_shortcode('wp_caption', 'fixed_img_caption_shortcode');
add_shortcode('caption', 'fixed_img_caption_shortcode');
function fixed_img_caption_shortcode($attr, $content = null) {
if ( ! isset( $attr['caption'] ) ) {
if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
$content = $matches[1];
$attr['caption'] = trim( $matches[2] );
}
}