public function testGetByFileName() { $imageFile = ImageFileModel::getById($this->imageFile1Id); $fileName = $imageFile->getImageCacheFileName(); $imageFileReturned = ImageFileModel::getByFileName($fileName); $this->assertTrue($imageFileReturned->isSame($imageFile)); try { $exceptionTriggered = false; ImageFileModel::getByFileName('nonExistantFileName'); } catch (NotFoundException $exception) { $exceptionTriggered = true; } $this->assertTrue($exceptionTriggered); }
public static function getImageFromHtmlImgTag($htmlContent) { assert('is_string($htmlContent)'); $matches = array(); preg_match("/<img.*src=[\"'](.*)[\"']/i", $htmlContent, $matches); // Not Coding Standard $url = $matches[1]; $matches = array(); if (preg_match("/\\?fileName\\=(.*)/i", $url, $matches) == 1) { $imageFileModel = ImageFileModel::getByFileName($matches[1]); return $imageFileModel; } else { $params = LabelUtil::getTranslationParamsForAllModules(); $icon = ZurmoHtml::tag('i', array('class' => 'icon-notice'), ''); $message = Zurmo::t('ZurmoModule', 'Due to recent improvements in the Zurmo email template builder, you are required ' . 'to re-import the image from the external URL. The image currently in use is located ' . 'here {url}. You can also select from an existing image in the gallery.', array_merge($params, array('{url}' => $url))); $message = ZurmoHtml::tag('p', array(), $message); return ZurmoHtml::tag('div', array('class' => 'image-legacy-message general-issue-notice'), $icon . $message); } }