You are here

public function HtmlMailMime::addHtmlImage in HTML Mail 8.3

Same name and namespace in other branches
  1. 8 src/Utility/HTMLMailMime.php \Drupal\htmlmail\Utility\HTMLMailMime::addHtmlImage()

Adds an image to the list of embedded images.

Parameters

string|array $file: The image file name OR image data itself.

string $content_type: (optional) The content-type of the image, such as "image/gif".

string $name: (optional) The filename of the image, if $is_file is FALSE.

bool $is_file: (optional) FALSE if $file contains the actual image data, rather than a filename. Defaults to TRUE.

int $content_id: (optional) The desired Content-ID for this MIME part.

Return value

bool TRUE if the file was successfully attached, and FALSE if it wasn't.

1 call to HtmlMailMime::addHtmlImage()
HtmlMailMime::attachRegex in src/Utility/HtmlMailMime.php
A preg_replace_callback used to attach local files, if possible.

File

src/Utility/HtmlMailMime.php, line 209

Class

HtmlMailMime
Class HtmlMailMime.

Namespace

Drupal\htmlmail\Utility

Code

public function addHtmlImage($file, $content_type = NULL, $name = '', $is_file = TRUE, $content_id = NULL) {
  $filename = $is_file ? $file : $name;
  if (empty($content_id)) {
    $content_id = md5($filename);
  }
  if (empty($content_type)) {
    $content_type = self::guessMimeType($filename);
  }
  if (!isset($this->cids[$content_id])) {
    $this->cids[$content_id] = self::successful(parent::addHTMLImage($file, $content_type, $name, $is_file, $content_id));
  }
  return $this->cids[$content_id];
}