I want to add the caption ALWAYS to images, even if it is empty. This is my function to add the caption, but the caption element will not be generated when there is no content in it, how to add the caption element always?
add_filter('img_caption_shortcode', 'caption_shortcode_inline_text', 10, 3);
function caption_shortcode_inline_text($empty, $attr, $content) {
extract(shortcode_atts(array(
'id' => '',
'align' => 'alignnone',
'width' => '',
'caption' => ''
), $attr));
// in this part I amtrying to always add the caption element but it doesn't work:
if (1 < (int) $width || 1 > (int) $width || $caption || !$caption)
return '<div ' . $id . 'class="wp-caption ' . esc_attr($align) . '" style="width: ' . (10 + (int) $width) . 'px">'
. do_shortcode($content) . '<p class="wp-caption-text">' . $caption . '</p></div>';
}
if (1 < (int) $width || 1 > (int) $width )
this will only consider the width property.if ( (int) $width != 1 ) { .... }
IF
and let itreturn
sistematically