-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[4.0] Fix images #35780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.0] Fix images #35780
Changes from 17 commits
08cd724
7fd6a59
f2bfbad
ce2e00f
e10da79
45ec5c4
dc10268
7962abb
c8132ff
9a0f4d7
6657f4c
60633dc
5d051b0
9bed5fc
ee4c197
8738949
9aae3cd
6810fad
707d717
47291e5
9d43461
5348c56
19d99ea
dd36e11
38e61c8
8efc2a2
1c8d811
d50b8b0
687d583
4c54bb5
6f67b9f
a2b71cb
9061a45
27d1bc4
e95e9ee
2557b33
885d9ec
c5fa812
1ce9cf4
bcaa805
a32c810
6a1dcc6
7f2f4fc
0990be1
fbbb8cc
ba3250b
b976276
1877d55
282fa98
bf34ca0
4fd81ee
7f312c1
4b64a15
9cc8b33
4865886
d0bbb00
6fce942
19ac361
cad01eb
020c806
6badaac
bba0545
a782b24
1ec83be
d0ba9b8
49c8ff6
4d5ff42
8f4d6d2
0da6cb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| use Joomla\CMS\HTML\HTMLHelper; | ||
| use Joomla\CMS\Language\Text; | ||
| use Joomla\CMS\Layout\FileLayout; | ||
| use Joomla\CMS\Layout\LayoutHelper; | ||
|
|
||
| ?> | ||
|
|
||
|
|
@@ -40,9 +41,9 @@ | |
| <?php $images = json_decode($this->item->images); ?> | ||
| <div class="com-newsfeeds-newsfeed newsfeed<?php echo $direction; ?>"> | ||
| <?php if ($this->params->get('display_num')) : ?> | ||
| <h1 class="<?php echo $direction; ?>"> | ||
| <?php echo $this->escape($this->params->get('page_heading')); ?> | ||
| </h1> | ||
| <h1 class="<?php echo $direction; ?>"> | ||
| <?php echo $this->escape($this->params->get('page_heading')); ?> | ||
| </h1> | ||
| <?php endif; ?> | ||
| <h2 class="<?php echo $direction; ?>"> | ||
| <?php if ($this->item->published == 0) : ?> | ||
|
|
@@ -61,30 +62,43 @@ | |
| <!-- Show Images from Component --> | ||
| <?php if (isset($images->image_first) && !empty($images->image_first)) : ?> | ||
| <?php $imgfloat = empty($images->float_first) ? $this->params->get('float_first') : $images->float_first; ?> | ||
| <?php $alt = empty($images->image_first_alt) && empty($images->image_first_alt_empty) | ||
| ? '' | ||
| : 'alt="' . htmlspecialchars($images->image_first_alt, ENT_COMPAT, 'UTF-8') . '"'; ?> | ||
|
|
||
| <div class="com-newsfeeds-newsfeed__first-image img-intro-<?php echo htmlspecialchars($imgfloat, ENT_COMPAT, 'UTF-8'); ?>"> | ||
| <img | ||
| <?php $imgAttribs = []; ?> | ||
| <?php if ($images->image_first_caption) : ?> | ||
| <?php echo 'class="caption" title="' . htmlspecialchars($images->image_first_caption, ENT_COMPAT, 'UTF-8') . '"'; ?> | ||
| <?php $imgAttribs['class'] = 'caption'; ?> | ||
| <?php $imgAttribs['title'] = htmlspecialchars($images->image_first_caption, ENT_COMPAT, 'UTF-8'); ?> | ||
|
||
| <?php endif; ?> | ||
| src="<?php echo htmlspecialchars($images->image_first, ENT_COMPAT, 'UTF-8'); ?>" <?php echo $alt; ?>> | ||
| <?php echo LayoutHelper::render( | ||
| 'joomla.html.image', | ||
| [ | ||
| 'image' => [ | ||
| 'src' => $images->image_first, | ||
| 'alt' => empty($images->image_first_alt) && empty($images->image_first_alt_empty) ? '' : $images->image_first_alt, | ||
dgrammatiko marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 'attributes' => $imgAttribs | ||
dgrammatiko marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ], | ||
| ] | ||
| ); ?> | ||
| </div> | ||
| <?php endif; ?> | ||
|
|
||
| <?php if (isset($images->image_second) and !empty($images->image_second)) : ?> | ||
| <?php $imgfloat = empty($images->float_second) ? $this->params->get('float_second') : $images->float_second; ?> | ||
| <?php $alt = empty($images->image_second_alt) && empty($images->image_second_alt_empty) | ||
| ? '' | ||
| : 'alt="' . htmlspecialchars($images->image_second_alt, ENT_COMPAT, 'UTF-8') . '"'; ?> | ||
| <div class="com-newsfeeds-newsfeed__second-image float-<?php echo htmlspecialchars($imgfloat, ENT_COMPAT, 'UTF-8'); ?> item-image"> | ||
| <img | ||
| <?php $imgAttribs = []; ?> | ||
| <?php if ($images->image_second_caption) : ?> | ||
| <?php echo 'class="caption" title="' . htmlspecialchars($images->image_second_caption) . '"'; ?> | ||
| <?php $imgAttribs['class'] = 'caption'; ?> | ||
| <?php $imgAttribs['title'] = htmlspecialchars($images->image_second_caption, ENT_COMPAT, 'UTF-8'); ?> | ||
| <?php endif; ?> | ||
| src="<?php echo htmlspecialchars($images->image_second, ENT_COMPAT, 'UTF-8'); ?>" <?php echo $alt; ?>> | ||
| <?php echo LayoutHelper::render( | ||
| 'joomla.html.image', | ||
| [ | ||
| 'image' => [ | ||
| 'src' => $images->image_second, | ||
| 'alt' => empty($images->image_second_alt) && empty($images->image_second_alt_empty) ? '' : $images->image_second_alt, | ||
| 'attributes' => $imgAttribs | ||
dgrammatiko marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ], | ||
| ] | ||
| ); ?> | ||
| </div> | ||
| <?php endif; ?> | ||
| <!-- Show Description from Component --> | ||
|
|
@@ -98,9 +112,18 @@ | |
| <?php endif; ?> | ||
|
|
||
| <!-- Show Image --> | ||
| <?php if ($this->rssDoc->image && $this->params->get('show_feed_image')) : ?> | ||
| <?php if ($this->rssDoc->image && $this->params->get('show_feed_image')) : ?> | ||
| <div class="com-newsfeeds-newsfeed__feed-image"> | ||
| <img src="<?php echo $this->rssDoc->image->uri; ?>" alt="<?php echo $this->rssDoc->image->title; ?>" /> | ||
| <?php echo LayoutHelper::render( | ||
| 'joomla.html.image', | ||
| [ | ||
| 'image' => [ | ||
| 'src' => $this->rssDoc->image->uri, | ||
| 'alt' => $this->rssDoc->image->title, | ||
| 'attributes' => [] | ||
dgrammatiko marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ], | ||
| ] | ||
| ); ?> | ||
| </div> | ||
| <?php endif; ?> | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?php | ||
| /** | ||
| * @package Joomla.Site | ||
| * @subpackage Layout | ||
| * | ||
| * @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org> | ||
| * @license GNU General Public License version 2 or later; see LICENSE.txt | ||
| */ | ||
|
|
||
| defined('_JEXEC') or die; | ||
|
|
||
| use Joomla\CMS\HTML\HTMLHelper; | ||
|
|
||
| extract($displayData); | ||
dgrammatiko marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| $imgAttribs = $image['attributes']; | ||
| $img = HTMLHelper::_('cleanImageURL', $image['src']); | ||
|
|
||
| if ($img->width > 0 && $img->height > 0) { | ||
| $imgAttribs['width'] = $img->width; | ||
| $imgAttribs['height'] = $img->height; | ||
| $imgAttribs['loading'] = 'lazy'; | ||
| } | ||
|
|
||
| echo HTMLHelper::_('image', htmlspecialchars($img->url, ENT_QUOTES, 'UTF-8'), htmlspecialchars($image['alt'], ENT_QUOTES, 'UTF-8'), $image['attributes']); | ||
Uh oh!
There was an error while loading. Please reload this page.