setResource($page); } static public function getDescription(): string { return "The image for social card"; } static public function getLabel(): string { return "Social Card Image"; } public static function getName(): string { return self::PROPERTY_NAME; } static public function getPersistenceType(): string { return Metadata::DERIVED_METADATA; } static public function isMutable(): bool { return false; } public function getValue(): WikiPath { $contextPage = $this->getResource(); $actual = $contextPage; while (true) { try { return $this->getFeaturedRasterImageOrFirst($actual); } catch (ExceptionNotFound $e) { // ok, vignette ? } try { $actual = $actual->getParent(); } catch (ExceptionNotFound $e) { break; } } try { return Site::getLogoAsRasterImage()->getSourcePath(); } catch (ExceptionNotFound $e) { return FeaturedRasterImage::getComboStrapLogo(); } } /** * @throws ExceptionNotFound */ private function getFeaturedRasterImageOrFirst(ResourceCombo $contextPage): WikiPath { $featuredRasterImage = FeaturedRasterImage::createFromResourcePage($contextPage); try { return $featuredRasterImage->getValueOrParsed(); } catch (ExceptionNotFound $e) { return FirstRasterImage::createForPage($contextPage)->getValue(); } } static public function getDrive(): string { return WikiPath::MEDIA_DRIVE; } }