ADD возможность вставлять фотки в статьи в исходном размере
This commit is contained in:
parent
34b5d8300e
commit
1773cc8a2b
|
|
@ -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 = '<div style="text-align: center;"><img src="/photos/articles/'.$size.'/' . $imgObj->name . '" title="' . $imgObj->caption . '" class="imageInArticle" /></div>';
|
||||
$imgTag = '<div style="text-align: center;"><img src="/photos/articles'.$currentSize.'/' . $imgObj->name . '" title="' . $imgObj->caption . '" class="imageInArticle" /></div>';
|
||||
$string = str_replace($img, $imgTag, $string);
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
Loading…
Reference in New Issue