You are here

private function GatherContentFunctions::addMediaToContent in GatherContent 7.2

Called from addMediaToEntity to insert media item into content.

1 call to GatherContentFunctions::addMediaToContent()
GatherContentFunctions::addMediaToEntity in includes/functions.inc
Used during media import to add downloaded media to node.

File

includes/functions.inc, line 93
Class containing general functions used throughout the importing. Extended by GatherContentCurl.

Class

GatherContentFunctions
@file Class containing general functions used throughout the importing. Extended by GatherContentCurl.

Code

private function addMediaToContent($value, $file_url, $filename, $filemime, $filter, $more_than_1, $counter) {
  $image_types = array(
    'image/gif',
    'image/jpeg',
    'image/png',
  );
  $image_file = in_array($filemime, $image_types);
  $tag = '#_gc_file_name_' . $counter . '#';
  $html = $file_url;
  if ($filter != 'plain_text') {
    if ($image_file) {
      $html = '<a href="' . $file_url . '"><img src="' . $file_url . '" alt="' . check_plain($filename) . '" /></a>';
    }
    else {
      $html = '<a href="' . $file_url . '">' . $filename . '</a>';
    }
  }
  $html = "\n" . $html . "\n";
  if ($more_than_1) {
    $html .= $tag;
  }
  return str_replace($tag, $html, $value);
}