private function insertImages($text, Ess_M2ePro_Model_Magento_Product $magentoProduct) { preg_match_all("/#image\\[(.*?)\\]#/", $text, $matches); if (!count($matches[0])) { return $text; } $imageLink = $magentoProduct->getImageLink('image'); $blockObj = Mage::getSingleton('core/layout')->createBlock('M2ePro/adminhtml_renderer_description_image'); $search = array(); $replace = array(); foreach ($matches[0] as $key => $match) { $tempImageAttributes = explode(',', $matches[1][$key]); $realImageAttributes = array(); for ($i = 0; $i < 6; $i++) { if (!isset($tempImageAttributes[$i])) { $realImageAttributes[$i] = 0; } else { $realImageAttributes[$i] = (int) $tempImageAttributes[$i]; } } $tempImageLink = $realImageAttributes[5] == 0 ? $imageLink : $magentoProduct->getGalleryImageLink($realImageAttributes[5]); $data = array('width' => $realImageAttributes[0], 'height' => $realImageAttributes[1], 'margin' => $realImageAttributes[2], 'linked_mode' => $realImageAttributes[3], 'watermark' => $realImageAttributes[4], 'src' => $tempImageLink); $search[] = $match; $replace[] = $tempImageLink == '' ? '' : preg_replace('/\\s{2,}/', '', $blockObj->addData($data)->toHtml()); } $text = str_replace($search, $replace, $text); return $text; }
public function getImageLink($attribute = 'image') { $cacheKey = array(__METHOD__, func_get_args()); if ($this->isCacheEnabled && !is_null($cacheResult = $this->getCache()->getData($cacheKey))) { return $cacheResult; } return $this->getCache()->setData($cacheKey, parent::getImageLink($attribute)); }