YJSoft/xe-module-seo

첨부없이 섬네일이 있는 경우 섬네일이미지를 출력하게...

Opened this issue · 1 comments

첨부파일이 있는 경우에 사이트이미지도 같이 출력되는 문제가 있어 아래와 같이 코드를 감싸서 사용하고 있습니다.

그런데 한가지 문제가 첨부가 없이 섬네일이 있는 경우도 섬네일이 표시 되지 못하고 사이트이미지가 출력되는데요. 첨부가 없이 섬네일을 가지고 있는 경우 섬네일이미지를 표시해줄 수 있게 고칠 수 있을까요??

	if($piece->image == null){
	if($config->site_image_url) {
		//if cache is supported, try to use it
		if($oCacheHandler->isSupport())
		{
			$cache_key = 'seo:site_image';
			$site_image = $oCacheHandler->get($cache_key);
			
			//if cache exists,use cache
			if($site_image)
			{
				$site_image['url'] = $config->site_image_url;
			}
			//else(no cache exists), re-generate cache
			else
			{
				list($width, $height) = @getimagesize(_XE_PATH_ . 'files/attach/site_image/' . $config->site_image);
				$site_image_dimension = array(
					'width' => $width,
					'height' => $height
				);
				$cache_key = 'seo:site_image';
				$oCacheHandler->put($cache_key, $site_image_dimension);
				
				$site_image = array(
					'url' => $config->site_image_url,
					'width' => $width,
					'height' => $height
				);
			}
		}
		//do not use cache if no cache available
		else
		{
			list($width, $height) = @getimagesize(_XE_PATH_ . 'files/attach/site_image/' . $config->site_image);
			$site_image = array(
				'url' => $config->site_image_url,
				'width' => $width,
				'height' => $height
			);
		}
		$piece->image[] = $site_image;
	}
	}

아래와 같이 처리했는데 잘 한건지 잘 모르겠습니다.

$getThumbnail = $oDocument->getThumbnail(300,300);

//if site image exists
if($piece->image == null){
//섬네일 추출, 섬네일 없으면 사이트 이미지 추출
$cache_key = 'seo:thumbnail';
$thumbnail = $oCacheHandler->get($cache_key);
if($getThumbnail){
$size = getimagesize(str_replace(getUrl(), './', $getThumbnail)); // 섬네일의 이미지 파일 정보 추출
$thumbnail['url'] = $getThumbnail;
$thumbnail['width'] = $size[0];
$thumbnail['height'] = $size[1];
$piece->image[] = $thumbnail;
} else if($config->site_image_url) {
//if cache is supported, try to use it
if($oCacheHandler->isSupport())
{
$cache_key = 'seo:site_image';
$site_image = $oCacheHandler->get($cache_key);

			//if cache exists,use cache
			if($site_image)
			{
				$site_image['url'] = $config->site_image_url;
			}
			//else(no cache exists), re-generate cache
			else
			{
				list($width, $height) = @getimagesize(_XE_PATH_ . 'files/attach/site_image/' . $config->site_image);
				$site_image_dimension = array(
					'width' => $width,
					'height' => $height
				);
				$cache_key = 'seo:site_image';
				$oCacheHandler->put($cache_key, $site_image_dimension);
				
				$site_image = array(
					'url' => $config->site_image_url,
					'width' => $width,
					'height' => $height
				);
			}
		}
		//do not use cache if no cache available
		else
		{
			list($width, $height) = @getimagesize(_XE_PATH_ . 'files/attach/site_image/' . $config->site_image);
			$site_image = array(
				'url' => $config->site_image_url,
				'width' => $width,
				'height' => $height
			);
		}
		$piece->image[] = $site_image;
	}
	}