From 1773cc8a2b750c4e0f3b27cb973b924196e0a485 Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Mon, 9 May 2016 20:28:40 +0300 Subject: [PATCH] =?UTF-8?q?ADD=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6?= =?UTF-8?q?=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=B2=D1=81=D1=82=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D1=8F=D1=82=D1=8C=20=D1=84=D0=BE=D1=82=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B2=20=D1=81=D1=82=D0=B0=D1=82=D1=8C=D0=B8=20=D0=B2=20=D0=B8?= =?UTF-8?q?=D1=81=D1=85=D0=BE=D0=B4=D0=BD=D0=BE=D0=BC=20=D1=80=D0=B0=D0=B7?= =?UTF-8?q?=D0=BC=D0=B5=D1=80=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Helper.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/classes/Helper.php b/classes/Helper.php index 8519472..bbe8662 100644 --- a/classes/Helper.php +++ b/classes/Helper.php @@ -63,14 +63,19 @@ class Helper public static function replaceImgs($string, $replaceType = 'clear', $size = 'middle') { - preg_match_all("(\[img[\|]#(\d+)\])", $string, $images); + preg_match_all("(\[img[\|]#(\d+)([\|](\w+))?\])", $string, $images); $images = isset($images[0]) ? $images[0] : FALSE; if ($images) { foreach ($images as $img) { $imgAndId = mb_substr($img, 2, -1); - $imgAndId = explode('#', $imgAndId); + $imgAndId = explode('|', $imgAndId); - $imgId = (int)$imgAndId[1]; + $imgId = intval(substr($imgAndId[1], 1)); + + $currentSize = '/'.$size; + if (isset($imgAndId[2]) && $imgAndId[2] == 'src') { + $currentSize = ''; + } $imgObj = ArticlePhotos::model()->getByPK($imgId); @@ -78,7 +83,7 @@ class Helper switch ($replaceType) { case 'html': $imgObj->caption = $linkTitle = str_replace('"', 'สบ', $imgObj->caption); - $imgTag = '
'; + $imgTag = '
'; $string = str_replace($img, $imgTag, $string); break; default: