mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-15 11:59:56 +00:00
move hook to render service
This commit is contained in:
parent
864e644343
commit
4536458992
|
@ -78,11 +78,15 @@ class PortableInfoboxRenderServiceHelper {
|
|||
*/
|
||||
public function extendImageData( $data ) {
|
||||
$thumbnail = $this->getThumbnail( $data[ 'name' ] );
|
||||
$ref = null;
|
||||
|
||||
if ( !$thumbnail ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wfRunHooks( 'PortableInfoboxNodeImage::getData', [ $data, &$ref ] );
|
||||
|
||||
$data[ 'ref' ] = $ref;
|
||||
$data[ 'height' ] = $thumbnail->getHeight();
|
||||
$data[ 'width' ] = $thumbnail->getWidth();
|
||||
$data[ 'thumbnail' ] = $thumbnail->getUrl();
|
||||
|
|
|
@ -27,15 +27,12 @@ class NodeImage extends Node {
|
|||
$alt = $this->getValueWithDefault( $this->xmlNode->{self::ALT_TAG_NAME} );
|
||||
$caption = $this->getValueWithDefault( $this->xmlNode->{self::CAPTION_TAG_NAME} );
|
||||
|
||||
wfRunHooks( 'PortableInfoboxNodeImage::getData', [ $title, &$ref, $caption ] );
|
||||
|
||||
$this->data = [
|
||||
'url' => $this->resolveImageUrl( $file ),
|
||||
'name' => ( $title ) ? $title->getText() : '',
|
||||
'key' => ( $title ) ? $title->getDBKey() : '',
|
||||
'alt' => $alt,
|
||||
'caption' => $caption,
|
||||
'ref' => $ref
|
||||
'caption' => $caption
|
||||
];
|
||||
|
||||
if ( $this->isVideo( $file ) ) {
|
||||
|
|
|
@ -4,6 +4,7 @@ use Wikia\PortableInfobox\Helpers\PortableInfoboxRenderServiceHelper;
|
|||
|
||||
class PortableInfoboxRenderService extends WikiaService {
|
||||
const MOBILE_TEMPLATE_POSTFIX = '-mobile';
|
||||
const MEDIA_CONTEXT_INFOBOX_HERO_IMAGE = 'infobox-hero-image';
|
||||
|
||||
private static $templates = [
|
||||
'wrapper' => 'PortableInfoboxWrapper.mustache',
|
||||
|
@ -128,6 +129,7 @@ class PortableInfoboxRenderService extends WikiaService {
|
|||
|
||||
if ( array_key_exists( 'image', $data ) ) {
|
||||
$data[ 'image' ] = $helper->extendImageData( $data[ 'image' ] );
|
||||
$data[ 'image' ][ 'context' ] = self::MEDIA_CONTEXT_INFOBOX_HERO_IMAGE;
|
||||
$markup = $this->renderItem( 'hero-mobile', $data );
|
||||
} else {
|
||||
$markup = $this->renderItem( 'title', $data[ 'title' ] );
|
||||
|
|
Loading…
Reference in a new issue