How to always add caption element to images – even if empty?

This works: add_filter( ‘disable_captions’, create_function(‘$a’, ‘return true;’) ); function image_send_to_editor_2($html, $id, $caption, $title, $align, $url, $size, $alt) { $width=”auto”; if ( preg_match( ‘/width=”([0-9]+)/’, $html, $matches ) ) { $width = $matches[1] . ‘px’; } $output=”<div id=”attachment-” . $id . ‘” class=”wp-caption align’ . $align . ‘” style=”width: ‘ . $width . ‘;”>’; $output .= $html; … Read more

Displaying “alt” attribute text as captions?

A WordPress approach If you have all your Images in the media gallery, you are able to access their post object while embedding/including the images via tinyMCE or plain PHP. WordPress uses wp_prepare_attachment_for_js to get all information about their images for their blade templates. Maybe this will help you to get started. A maybe approach … Read more