Site icon Hip-Hop Website Design and Development

Forcing max-width for picture captions

I’ve carried out a filter to my picture captions based mostly on this query I requested just a few days in the past. How can I slip into the caption the css fashion of max-width as nicely? I feel it may be achieved with preg_replace, however I can not get it to work.

All I actually am attempting to do is pressure the picture caption textual content to wrap contained in the div.

The default html output appears to be like like…

<div id="attachment_1071" fashion="width: 310px" class="wp-caption alignright">

I want it to seem like…

<div id="attachment_1071" fashion="width: 310px; max-width:310px;" class="wp-caption alignright">

Here’s what the filter at present appears to be like like…

operate my_caption_shortcode($atts) {
  if (isset($atts['caption'])) {
    remove_filter( current_filter(), __FUNCTION__);
    $atts['caption'] = do_shortcode($atts['caption']);
    add_filter(current_filter(), __FUNCTION__);
  }
  //preg_replace("/width:{????}px/i", "width:{1}px; max-width:{1}px;", $atts['caption']);
  return $atts;
}