mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 17:51:40 +09:00
Fix #1254 use cover image first when extracting images for SEO
This commit is contained in:
parent
6a43274826
commit
8e593a9d60
2 changed files with 14 additions and 15 deletions
|
|
@ -489,30 +489,26 @@ class HTMLDisplayHandler
|
||||||
$document_images = array();
|
$document_images = array();
|
||||||
if ($oDocument->hasUploadedFiles())
|
if ($oDocument->hasUploadedFiles())
|
||||||
{
|
{
|
||||||
foreach ($oDocument->getUploadedFiles() as $file)
|
$document_files = $oDocument->getUploadedFiles();
|
||||||
|
usort($document_files, function($a, $b) {
|
||||||
|
return ord($b->cover_image) - ord($a->cover_image);
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach ($document_files as $file)
|
||||||
{
|
{
|
||||||
if ($file->isvalid !== 'Y' || !preg_match('/\.(?:bmp|gif|jpe?g|png)$/i', $file->uploaded_filename))
|
if ($file->isvalid !== 'Y' || !preg_match('/\.(?:bmp|gif|jpe?g|png)$/i', $file->uploaded_filename))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($width, $height) = @getimagesize($file->uploaded_filename);
|
list($width, $height) = @getimagesize($file->uploaded_filename);
|
||||||
if ($width < 100 && $height < 100)
|
if ($width < 100 && $height < 100)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$image = array('filepath' => $file->uploaded_filename, 'width' => $width, 'height' => $height);
|
|
||||||
if ($file->cover_image === 'Y')
|
$document_images[] = array('filepath' => $file->uploaded_filename, 'width' => $width, 'height' => $height);
|
||||||
{
|
break;
|
||||||
array_unshift($document_images, $image);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$document_images[] = $image;
|
|
||||||
}
|
|
||||||
if (count($document_images) >= 1)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rhymix\Framework\Cache::set("seo:document_images:$document_srl", $document_images);
|
Rhymix\Framework\Cache::set("seo:document_images:$document_srl", $document_images);
|
||||||
|
|
@ -525,7 +521,7 @@ class HTMLDisplayHandler
|
||||||
|
|
||||||
if ($document_images)
|
if ($document_images)
|
||||||
{
|
{
|
||||||
$first_image = reset($document_images);
|
$first_image = array_first($document_images);
|
||||||
$first_image['filepath'] = preg_replace('/^.\\/files\\//', \RX_BASEURL . 'files/', $first_image['filepath']);
|
$first_image['filepath'] = preg_replace('/^.\\/files\\//', \RX_BASEURL . 'files/', $first_image['filepath']);
|
||||||
Context::addOpenGraphData('og:image', Rhymix\Framework\URL::getCurrentDomainURL($first_image['filepath']));
|
Context::addOpenGraphData('og:image', Rhymix\Framework\URL::getCurrentDomainURL($first_image['filepath']));
|
||||||
Context::addOpenGraphData('og:image:width', $first_image['width']);
|
Context::addOpenGraphData('og:image:width', $first_image['width']);
|
||||||
|
|
|
||||||
|
|
@ -970,6 +970,7 @@ class documentController extends document
|
||||||
|
|
||||||
//remove from cache
|
//remove from cache
|
||||||
Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($obj->document_srl) . $obj->document_srl);
|
Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($obj->document_srl) . $obj->document_srl);
|
||||||
|
Rhymix\Framework\Cache::delete('seo:document_images:' . $obj->document_srl);
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1100,6 +1101,7 @@ class documentController extends document
|
||||||
|
|
||||||
//remove from cache
|
//remove from cache
|
||||||
Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($document_srl) . $document_srl);
|
Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($document_srl) . $document_srl);
|
||||||
|
Rhymix\Framework\Cache::delete('seo:document_images:' . $document_srl);
|
||||||
unset($GLOBALS['XE_DOCUMENT_LIST'][$document_srl]);
|
unset($GLOBALS['XE_DOCUMENT_LIST'][$document_srl]);
|
||||||
unset($GLOBALS['XE_EXTRA_VARS'][$document_srl]);
|
unset($GLOBALS['XE_EXTRA_VARS'][$document_srl]);
|
||||||
return $output;
|
return $output;
|
||||||
|
|
@ -1256,6 +1258,7 @@ class documentController extends document
|
||||||
|
|
||||||
// Clear cache
|
// Clear cache
|
||||||
Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($oDocument->document_srl) . $oDocument->document_srl);
|
Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($oDocument->document_srl) . $oDocument->document_srl);
|
||||||
|
Rhymix\Framework\Cache::delete('seo:document_images:' . $oDocument->document_srl);
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue