You are here

function _picture_filter_process in Picture 7

Same name and namespace in other branches
  1. 7.2 picture.module \_picture_filter_process()

Process callback for inline image filter.

1 string reference to '_picture_filter_process'
picture_filter_info in ./picture.module
Implements hook_filter_info().

File

./picture.module, line 1195
Picture formatter.

Code

function _picture_filter_process($text, $filter) {

  // Find all img tags with a data-picture-group attribute.
  preg_match_all('/<img.*?data-picture-group=".*?>/i', $text, $images);
  if (!empty($images[0])) {
    foreach ($images[0] as $image) {

      // Create the render array expected by theme_picture_formatter.
      $image_render_array = _picture_filter_prepare_image($image);
      if (!$image_render_array) {
        continue;
      }

      // Get the responsive markup for this image.
      $new_markup = theme('picture_formatter', $image_render_array);

      // Replace the original img tag with the responsive markup.
      $text = str_replace($image, $new_markup, $text);
    }
  }
  return $text;
}