Хак Добавление в запись уменьшенные и средние картинки из новости » Techno-сo — Портал для вебмастера

Все мы знаем тег {image-X}, который выводит ссылку на изображение из новости. Однако нужно, чтобы был тег, который бы выводил по аналогии уменьшенные копии изображений, а также средние.

Предлагаем теги {thumb-X} и {medium-X}.

Работает в короткой новости, в полной новости и для тега {custom}

Инструкция:

В файле engine/modules/show.short.php найти:

if (stripos ( $tpl->copy_template, "{image-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['short_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

if ( count($images) ) {
$i_count=0;
foreach($images as $url) {
$i_count++;
$tpl->copy_template = str_replace( '{image-'.$i_count.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[image-'.$i_count.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/image-'.$i_count.']', "", $tpl->copy_template );
}

}

$tpl->copy_template = preg_replace( "#[image-(.+?)](.+?)[/image-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{image-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

}

Заменить на:

// Доработка
if (stripos ( $tpl->copy_template, "{thumb-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['short_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

        
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

        
if ( count($images) ) {
$i_count=0;
foreach($images as $url) {
$i_count++;
$url2 = explode("/", $url);
if(in_array('medium', $url2)) {
$url2[count($url2)-2] = "thumbs";
$url = implode("/", $url2);
} else
if(!in_array('thumbs', $url2)) {
$url2[count($url2)-1] = "thumbs/" . $url2[count($url2)-1];
$url = implode("/", $url2);
}
$tpl->copy_template = str_replace( '{thumb-'.$i_count.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[thumb-'.$i_count.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/thumb-'.$i_count.']', "", $tpl->copy_template );
}

        
}

        
$tpl->copy_template = preg_replace( "#[thumb-(.+?)](.+?)[/thumb-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{thumb-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

        
}

        
if (stripos ( $tpl->copy_template, "{medium-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['short_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

        
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

        
if ( count($images) ) {
$i_count=0;
foreach($images as $url) {
$i_count++;
$url2 = explode("/", $url);
if(in_array('thumbs', $url2)) {
$url2[count($url2)-2] = "medium";
$url = implode("/", $url2);
} else
if(!in_array('medium', $url2)) {
$url2[count($url2)-1] = "medium/" . $url2[count($url2)-1];
$url = implode("/", $url2);
}
$tpl->copy_template = str_replace( '{medium-'.$i_count.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[medium-'.$i_count.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/medium-'.$i_count.']', "", $tpl->copy_template );
}

        
}

        
$tpl->copy_template = preg_replace( "#[medium-(.+?)](.+?)[/medium-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{medium-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

        
}

        
if (stripos ( $tpl->copy_template, "{image-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['short_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

        
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

        
if ( count($images) ) {
$i_count=0;
foreach($images as $url) {
$i_count++;
$url2 = explode("/", $url);
if(in_array('thumbs', $url2) OR in_array('medium', $url2)) {
$url2[count($url2)-2] = "";
$url = implode("/", $url2);
}
$tpl->copy_template = str_replace( '{image-'.$i_count.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[image-'.$i_count.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/image-'.$i_count.']', "", $tpl->copy_template );
}

        
}

        
$tpl->copy_template = preg_replace( "#[image-(.+?)](.+?)[/image-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{image-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

        
}

        
// Доработка

В файле engine/modules/show.full.php найти

if (stripos ( $tpl->copy_template, "{image-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['short_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

if ( count($images) ) {
$i=0;
foreach($images as $url) {
$i++;
$tpl->copy_template = str_replace( '{image-'.$i.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[image-'.$i.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/image-'.$i.']', "", $tpl->copy_template );
}

}

$tpl->copy_template = preg_replace( "#[image-(.+?)](.+?)[/image-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{image-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

}

        

        
if (stripos ( $tpl->copy_template, "{fullimage-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['full_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

if ( count($images) ) {
$i=0;
foreach($images as $url) {
$i++;
$tpl->copy_template = str_replace( '{fullimage-'.$i.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[fullimage-'.$i.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/fullimage-'.$i.']', "", $tpl->copy_template );
}

}

$tpl->copy_template = preg_replace( "#[fullimage-(.+?)](.+?)[/fullimage-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{fullimage-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

}

Заменить на:

// Доработка
if (stripos ( $tpl->copy_template, "{thumb-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['short_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

        
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

        
if ( count($images) ) {
$i=0;
foreach($images as $url) {
$i++;
$url2 = explode("/", $url);
if(in_array('medium', $url2)) {
$url2[count($url2)-2] = "thumbs";
$url = implode("/", $url2);
} else
if(!in_array('thumbs', $url2)) {
$url2[count($url2)-1] = "thumbs/" . $url2[count($url2)-1];
$url = implode("/", $url2);
}
$tpl->copy_template = str_replace( '{thumb-'.$i.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[thumb-'.$i.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/thumb-'.$i.']', "", $tpl->copy_template );
}

        
}

        
$tpl->copy_template = preg_replace( "#[thumb-(.+?)](.+?)[/thumb-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{thumb-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

        
}

        
if (stripos ( $tpl->copy_template, "{medium-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['short_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

        
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

        
if ( count($images) ) {
$i=0;
foreach($images as $url) {
$i++;
$url2 = explode("/", $url);
if(in_array('thumbs', $url2)) {
$url2[count($url2)-2] = "medium";
$url = implode("/", $url2);
} else
if(!in_array('medium', $url2)) {
$url2[count($url2)-1] = "medium/" . $url2[count($url2)-1];
$url = implode("/", $url2);
}
$tpl->copy_template = str_replace( '{medium-'.$i.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[medium-'.$i.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/medium-'.$i.']', "", $tpl->copy_template );
}

        
}

        
$tpl->copy_template = preg_replace( "#[medium-(.+?)](.+?)[/medium-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{medium-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

        
}

        
if (stripos ( $tpl->copy_template, "{fullthumb-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['full_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

        
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

        
if ( count($images) ) {
$i=0;
foreach($images as $url) {
$i++;
$url2 = explode("/", $url);
if(in_array('medium', $url2)) {
$url2[count($url2)-2] = "thumbs";
$url = implode("/", $url2);
} else
if(!in_array('thumbs', $url2)) {
$url2[count($url2)-1] = "thumbs/" . $url2[count($url2)-1];
$url = implode("/", $url2);
}
$tpl->copy_template = str_replace( '{fullthumb-'.$i.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[fullthumb-'.$i.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/fullthumb-'.$i.']', "", $tpl->copy_template );
}

        
}

        
$tpl->copy_template = preg_replace( "#[fullthumb-(.+?)](.+?)[/fullthumb-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{fullthumb-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

        
}

        
if (stripos ( $tpl->copy_template, "{fullmedium-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['full_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

        
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

        
if ( count($images) ) {
$i=0;
foreach($images as $url) {
$i++;
$url2 = explode("/", $url);
if(in_array('thumbs', $url2)) {
$url2[count($url2)-2] = "medium";
$url = implode("/", $url2);
} else
if(!in_array('medium', $url2)) {
$url2[count($url2)-1] = "medium/" . $url2[count($url2)-1];
$url = implode("/", $url2);
}
$tpl->copy_template = str_replace( '{fullmedium-'.$i.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[fullmedium-'.$i.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/fullmedium-'.$i.']', "", $tpl->copy_template );
}

        
}

        
$tpl->copy_template = preg_replace( "#[fullmedium-(.+?)](.+?)[/fullmedium-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{fullmedium-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

        
}

        
if (stripos ( $tpl->copy_template, "{image-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['short_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

        
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

        
if ( count($images) ) {
$i=0;
foreach($images as $url) {
$i++;
$url2 = explode("/", $url);
if(in_array('thumbs', $url2) OR in_array('medium', $url2)) {
$url2[count($url2)-2] = "";
$url = implode("/", $url2);
}
$tpl->copy_template = str_replace( '{image-'.$i.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[image-'.$i.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/image-'.$i.']', "", $tpl->copy_template );
}

        
}

        
$tpl->copy_template = preg_replace( "#[image-(.+?)](.+?)[/image-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{image-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

        
}

        
if (stripos ( $tpl->copy_template, "{fullimage-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['full_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

        
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

        
if ( count($images) ) {
$i=0;
foreach($images as $url) {
$i++;
$url2 = explode("/", $url);
if(in_array('thumbs', $url2) OR in_array('medium', $url2)) {
$url2[count($url2)-2] = "";
$url = implode("/", $url2);
}
$tpl->copy_template = str_replace( '{fullimage-'.$i.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[fullimage-'.$i.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/fullimage-'.$i.']', "", $tpl->copy_template );
}

        
}

        
$tpl->copy_template = preg_replace( "#[fullimage-(.+?)](.+?)[/fullimage-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{fullimage-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

        
}

        
// Доработка

В файле engine/modules/show.custom.php найти:

if (stripos ( $tpl->copy_template, "{image-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['short_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

        
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

        
if ( count($images) ) {
$i_count=0;
foreach($images as $url) {
$i_count++;
$tpl->copy_template = str_replace( '{image-'.$i_count.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[image-'.$i_count.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/image-'.$i_count.']', "", $tpl->copy_template );
}

        
}

        
$tpl->copy_template = preg_replace( "#[image-(.+?)](.+?)[/image-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{image-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

        
}

Заменить на:

// Доработка
if (stripos ( $tpl->copy_template, "{thumb-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['short_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

        
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

        
if ( count($images) ) {
$i_count=0;
foreach($images as $url) {
$i_count++;
$url2 = explode("/", $url);
if(in_array('medium', $url2)) {
$url2[count($url2)-2] = "thumbs";
$url = implode("/", $url2);
} else
if(!in_array('thumbs', $url2)) {
$url2[count($url2)-1] = "thumbs/" . $url2[count($url2)-1];
$url = implode("/", $url2);
}
$tpl->copy_template = str_replace( '{thumb-'.$i_count.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[thumb-'.$i_count.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/thumb-'.$i_count.']', "", $tpl->copy_template );
}

        
}

        
$tpl->copy_template = preg_replace( "#[thumb-(.+?)](.+?)[/thumb-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{thumb-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

        
}

        
if (stripos ( $tpl->copy_template, "{medium-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['short_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

        
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

        
if ( count($images) ) {
$i_count=0;
foreach($images as $url) {
$i_count++;
$url2 = explode("/", $url);
if(in_array('thumbs', $url2)) {
$url2[count($url2)-2] = "medium";
$url = implode("/", $url2);
} else
if(!in_array('medium', $url2)) {
$url2[count($url2)-1] = "medium/" . $url2[count($url2)-1];
$url = implode("/", $url2);
}
$tpl->copy_template = str_replace( '{medium-'.$i_count.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[medium-'.$i_count.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/medium-'.$i_count.']', "", $tpl->copy_template );
}

        
}

        
$tpl->copy_template = preg_replace( "#[medium-(.+?)](.+?)[/medium-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{medium-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

        
}

        
if (stripos ( $tpl->copy_template, "{image-" ) !== false) {

        
$images = array();
preg_match_all('/(img|src)=("|')[^"'>]+/i', $row['short_story'], $media);
$data=preg_replace('/(img|src)("|'|="|=')(.*)/i',"$3",$media[0]);

        
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}

        
if ( count($images) ) {
$i_count=0;
foreach($images as $url) {
$i_count++;
$url2 = explode("/", $url);
if(in_array('thumbs', $url2) OR in_array('medium', $url2)) {
$url2[count($url2)-2] = "";
$url = implode("/", $url2);
}
$tpl->copy_template = str_replace( '{image-'.$i_count.'}', $url, $tpl->copy_template );
$tpl->copy_template = str_replace( '[image-'.$i_count.']', "", $tpl->copy_template );
$tpl->copy_template = str_replace( '[/image-'.$i_count.']', "", $tpl->copy_template );
}

        
}

        
$tpl->copy_template = preg_replace( "#[image-(.+?)](.+?)[/image-(.+?)]#is", "", $tpl->copy_template );
$tpl->copy_template = preg_replace( "#\{image-(.+?)\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );

        
}

        
// Доработка

Иногда нужно сделать так, чтобы в новостях всегда создавались файлы уменьшенной копии и средней копии изображения.

Для этого нужно внести изменения:

В файле uploadengineclassesthumb.class.php найти:

if( $this->img['lebar'] img['tinggi'] img['lebar_thumb'] = $this->img['lebar'];
$this->img['tinggi_thumb'] = $this->img['tinggi'];
return 0;
}

Заменить на:

if( $this->img['lebar'] img['tinggi'] img['lebar'];
}

Проверялось на DLE 10.5.шаблоны для dle 11.2