Add images to weblink single view

This commit is contained in:
chmst 2021-08-14 12:46:56 +02:00
parent 19c67005f0
commit 0ed90865ca
1 changed files with 47 additions and 1 deletions

View File

@ -10,6 +10,7 @@
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\String\PunycodeHelper;
$weblinkUrl = PunycodeHelper::urlToUTF8($this->item->url);
@ -29,7 +30,52 @@ $weblinkUrl = PunycodeHelper::urlToUTF8($this->item->url);
<a href="<?php echo $weblinkUrl; ?>" target="_blank" itemprop="url">
<?php echo $weblinkUrl; ?>
</a>
<?php echo $this->item->description; ?>
<?php if (($this->params->get('show_link_description')) && ($this->item->description != '')) : ?>
<div class="mt-2 mb-2">
<?php $images = json_decode($this->item->images); ?>
<?php if (!empty($images->image_first)) : ?>
<?php $imgFloat = '';
if (!empty($images->float_first)) :
$imgFloat = $images->float_first == 'right' ? 'float-end' : 'float-start';
endif;
$img = HTMLHelper::cleanImageURL($images->image_first);
$alt = empty($images->image_first_alt) && empty($images->image_first_alt_empty)
? ''
: 'alt="' . htmlspecialchars($images->image_first_alt, ENT_COMPAT, 'UTF-8') . '"';
?>
<figure class="item-image <?php echo $imgFloat; ?>">
<img src="<?php echo htmlspecialchars($img->url, ENT_COMPAT, 'UTF-8'); ?>"
<?php echo $alt; ?> itemprop="thumbnail" />
<?php if (!empty($images->image_first_caption)) : ?>
<figcaption class="caption"><?php echo htmlspecialchars($images->image_first_caption, ENT_COMPAT, 'UTF-8'); ?></figcaption>
<?php endif; ?>
</figure>
<?php endif; ?>
<?php if (!empty($images->image_second)) : ?>
<?php $imgFloat = '';
if (!empty($images->float_second)) :
$imgFloat = $images->float_second == 'right' ? 'float-end' : 'float-start';
endif;
$img = HTMLHelper::cleanImageURL($images->image_second);
$alt = empty($images->image_first_alt) && empty($images->image_second_alt_empty)
? ''
: 'alt="' . htmlspecialchars($images->image_second_alt, ENT_COMPAT, 'UTF-8') . '"';
?>
<figure class="item-image <?php echo $imgFloat; ?>">
<img src="<?php echo htmlspecialchars($img->url, ENT_COMPAT, 'UTF-8'); ?>"
<?php echo $alt; ?> itemprop="thumbnail" />
<?php if (!empty($images->image_second_caption)) : ?>
<figcaption class="caption"><?php echo htmlspecialchars($images->image_second_caption, ENT_COMPAT, 'UTF-8'); ?></figcaption>
<?php endif; ?>
</figure>
<?php endif; ?>
<?php echo $this->item->description; ?>
</div>
<?php endif; ?>
</div>
<?php // Content is generated by content plugin event "onContentAfterDisplay" ?>
<?php echo $this->item->event->afterDisplayContent; ?>