From 49e0dd650caccbbb1636d9cb1091cfd8cf003bf8 Mon Sep 17 00:00:00 2001 From: Mischa Gorinskat Date: Thu, 16 Jul 2015 18:09:20 +0200 Subject: [PATCH] TW-236: Disabled escpaing when RichTextCaption setting is on --- newscoop/include/smarty/campsite_plugins/block.image.php | 8 +++++++- newscoop/template_engine/metaclasses/MetaImage.php | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/newscoop/include/smarty/campsite_plugins/block.image.php b/newscoop/include/smarty/campsite_plugins/block.image.php index a6db6fbbde..87f4d2f176 100644 --- a/newscoop/include/smarty/campsite_plugins/block.image.php +++ b/newscoop/include/smarty/campsite_plugins/block.image.php @@ -60,11 +60,17 @@ function smarty_block_image(array $params, $content, Smarty_Internal_Template $s } $imageService = \Zend_Registry::get('container')->getService('image'); + $preferencesService = \Zend_Registry::get('container')->getService('preferences'); + $caption = $imageService->getCaption($articleRendition->getImage(), $article->number, $article->language->number); + if ($preferencesService->get('MediaRichTextCaptions', 'N') == 'N') { + $caption = MetaDbObject::htmlFilter($caption); + } + $smarty->assign('image', (object) array( 'src' => \Zend_Registry::get('view')->url(array('src' => $image['src']), 'image', true, false), 'width' => $image['width'], 'height' => $image['height'], - 'caption' => $imageService->getCaption($articleRendition->getImage(), $article->number, $article->language->number), + 'caption' => $caption, 'description' => $articleRendition->getImage()->getDescription(), 'photographer' => $articleRendition->getImage()->getPhotographer(), 'original' => $image['original'], diff --git a/newscoop/template_engine/metaclasses/MetaImage.php b/newscoop/template_engine/metaclasses/MetaImage.php index b6391dd501..4e839066ea 100644 --- a/newscoop/template_engine/metaclasses/MetaImage.php +++ b/newscoop/template_engine/metaclasses/MetaImage.php @@ -56,6 +56,11 @@ public function __construct($p_imageId = null) $this->m_customProperties['type'] = 'getType'; $this->m_customProperties['photographer_url'] = 'getPhotographerUrl'; $this->m_customProperties['caption'] = 'getCaption'; + + $preferencesService = \Zend_Registry::get('container')->getService('preferences'); + if ($preferencesService->MediaRichTextCaptions == 'Y') { + $this->m_skipFilter = array('caption'); + } } // fn __construct