5.11.15, 11:09
0 комментарий
  DLE Хаки

Хак Добавление в запись уменьшенные и средние картинки из новости

Все мы знаем тег {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 );

	
}

	
// Доработка


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

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

В файле \upload\engine\classes\thumb.class.php найти:

if( $this->img['lebar'] <= $size and $this->img['tinggi'] <= $size ) {
$this->img['lebar_thumb'] = $this->img['lebar'];
$this->img['tinggi_thumb'] = $this->img['tinggi'];
return 0;
}


Заменить на:

if( $this->img['lebar'] <= $size and $this->img['tinggi'] <= $size ) {
$size = $this->img['lebar'];
}



Проверялось на DLE 10.5.

Реклама

Напишите своё мнение

  • acuteaggressiveair_kissangel
    badbbbeachbeee
    biggrinbig_bossblumblush
    boastbombboredombye
    clappingcraycrazycurtsey
    dancedashdeclarediablo
    diroldon-t_mentiondownloaddrinks
    first_moveflirtfocusfool
    friendsgive_heartgive_rosegood
    hangheartheathelp
    hihunterhystericireful
    kingkisslaughlazy
    lolmail1mambaman_in_love
    mdamega_shokmoilmosking
    musicneanegativenew_russian
    okon_the_quietpardonparting
    partypilotpioneerpleasantry
    popcormpranksterprevedpunish
    roflrtfmrussiansad
    sarcasticscarescratchsearch
    secretsensoredshokshout
    slowsmilesmokesoldier
    soldier_girlsorryspitefulspruce_up
    stinkersuicidesunsuperstition
    swoonteasetenderthanks
    thisto_pick_ones_noseto_take_umbragetreaten
    umnikunknwvampirevava
    victorywackowhistlewink
    wizardyahooyesyu
    e101e102e103e104
    e105e106e107e108
    e109e110e111e112
    e113e114e115e116
    e117e118e119e120
    e121e122e123e124
    e125e126e127e128
    e129e130e131e132
    e133e134e135e136
    e137e138e139e140
    e141e142e143e144
    e145e146e147e148
    e149e150e151e152
    e153e154e155e156
    e157e158e159e160
    e161e162e163e164
    e165e166e167e168
    e169e170e171e172
    e173e174e175e176
    e177e178e179e180
    e181e182e183e184
    e185e186e187e188
    e189e190e191e192
    e193e194e195e196
    e197e198e199e200
    e201e202e203e204