function extractImagesIntoInlineParts(&$Mail, $options = array()) { $html =& $Mail->body; require_once(AK_LIB_DIR.DS.'AkActionView'.DS.'helpers'.DS.'text_helper.php'); $images = TextHelper::get_image_urls_from_html($html); $html_images = array(); if(!empty($images)){ require_once(AK_LIB_DIR.DS.'AkImage.php'); require_once(AK_LIB_DIR.DS.'AkActionView'.DS.'helpers'.DS.'asset_tag_helper.php'); $images = array_diff(array_unique($images), array('')); foreach ($images as $image){ $original_image_name = $image; $image = $this->_getImagePath($image); if(!empty($image)){ $extenssion = substr($image, strrpos('.'.$image,'.')); $image_name = Ak::uuid().'.'.$extenssion; $html_images[$original_image_name] = 'cid:'.$image_name; $Mail->setAttachment('image/'.$extenssion, array( 'body' => Ak::file_get_contents($image), 'filename' => $image_name, 'content_disposition' => 'inline', 'content_id' => '<'.$image_name.'>', )); } } $modified_html = str_replace(array_keys($html_images),array_values($html_images), $html); if($modified_html != $html){ $html = $modified_html; $Mail->_moveBodyToInlinePart(); } } }
function _embedReferencedImages($html) { $images = TextHelper::get_image_urls_from_html($html); $html_images = array(); if (!empty($images)) { require_once AK_LIB_DIR . DS . 'AkImage.php'; require_once AK_LIB_DIR . DS . 'AkActionView' . DS . 'helpers' . DS . 'asset_tag_helper.php'; foreach ($images as $image) { $image = AssetTagHelper::_compute_public_path($image); $extenssion = substr($image, strrpos('.' . $image, '.')); $image_name = Ak::uuid(); Ak::file_put_contents(AK_CACHE_DIR . DS . 'tmp' . DS . $image_name . $extenssion, file_get_contents($image)); $NewImage =& new AkImage(AK_CACHE_DIR . DS . 'tmp' . DS . $image_name . $extenssion); $NewImage->save(AK_CACHE_DIR . DS . 'tmp' . DS . $image_name . '.png'); $html_images[$image] = $image_name . '.png'; Ak::file_delete(AK_CACHE_DIR . DS . 'tmp' . DS . $image_name); } $html = str_replace(array_keys($html_images), array_values($html_images), $html); } return array($html_images, $html); }