Use original image as preview
This commit is contained in:
parent
90f4de5885
commit
390915a884
2 changed files with 3 additions and 25 deletions
|
@ -89,28 +89,6 @@ class Blog
|
||||||
return $htmlPicture;
|
return $htmlPicture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMediaPreviewURL(int $mediaID): string
|
|
||||||
{
|
|
||||||
$url = '';
|
|
||||||
|
|
||||||
$media = self::getMedia($mediaID);
|
|
||||||
$mediaSizes = (array) $media->media_details->sizes;
|
|
||||||
uasort(
|
|
||||||
$mediaSizes,
|
|
||||||
function ($a, $b) {
|
|
||||||
$sizeA = $a->width + $a->height;
|
|
||||||
$sizeB = $b->width + $b->height;
|
|
||||||
|
|
||||||
return $sizeA <=> $sizeB;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$mediaSmallest = (object) reset($mediaSizes);
|
|
||||||
|
|
||||||
$url = $mediaSmallest->source_url;
|
|
||||||
|
|
||||||
return $url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCategory(int $categoryID): \stdClass
|
public static function getCategory(int $categoryID): \stdClass
|
||||||
{
|
{
|
||||||
$category = self::get(sprintf(self::ENDPOINT_CATEGORIES, $categoryID));
|
$category = self::get(sprintf(self::ENDPOINT_CATEGORIES, $categoryID));
|
||||||
|
|
|
@ -11,12 +11,12 @@ namespace wishthis;
|
||||||
$postSlug = $_SESSION['_GET']['slug'];
|
$postSlug = $_SESSION['_GET']['slug'];
|
||||||
$post = Blog::getPostBySlug($postSlug);
|
$post = Blog::getPostBySlug($postSlug);
|
||||||
$postMediaHTML = isset($post->featured_media) ? Blog::getMediaHTML($post->featured_media) : '';
|
$postMediaHTML = isset($post->featured_media) ? Blog::getMediaHTML($post->featured_media) : '';
|
||||||
$postMediaURL = isset($post->featured_media) ? Blog::getMediaPreviewURL($post->featured_media) : '';
|
$postMedia = isset($post->featured_media) ? Blog::getMedia($post->featured_media) : new \stdClss();
|
||||||
|
|
||||||
$page = new Page(__FILE__, $post->title->rendered);
|
$page = new Page(__FILE__, $post->title->rendered);
|
||||||
|
|
||||||
if ('' !== $postMediaURL) {
|
if (isset($postMedia->source_url)) {
|
||||||
$page->link_preview = $postMediaURL;
|
$page->link_preview = $postMedia->source_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
$page->header();
|
$page->header();
|
||||||
|
|
Loading…
Reference in a new issue