You are here

public function HTMLMailMime::addHtmlImage in HTML Mail 8

Same name and namespace in other branches
  1. 8.3 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 199
Provides the MailMIME class for creating MIME-formatted email messages.

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];
}