User tests: Successful: Unsuccessful:
Preventing Notices for articles image_intro_caption
and image_fulltext_caption
when these fields are empty
Display a blog of articles for which you have not set any image captions whether for full or intro text.
Display a full single article.
In both cases you will get a Notice
Trying to get property of non-object in ROOT//layouts/joomla/content/intro_image.php on line 16
and
Trying to get property of non-object in ROOT//layouts/joomla/content/full_image.php on line 14
Patch and test again.
NOTE: When we have captions, they display on top of the image and not below. This PR does not correct this.
Status | New | ⇒ | Pending |
Category | ⇒ | Layout |
Good catch (shame on me)
@SharkyKZ is spot on. You can remove that caption variable.
I had this added originally because the caption was tested in two places, but the second place was removed again later. So it's superfluous now.
As for the caption before the image or after, I don't know anymore why I did it this way, probably worked from an example where it was like this. It can sure be changed.
I have tested this item
Just saw the comments, will retest when the suggested changes are done.
Labels |
Added:
?
|
Got rid of the $caption variable.
Will make a new PR after merge to display the caption under the image as it is the most common way for a caption.
I have tested this item
I have tested this item
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-05-21 07:38:45 |
Closed_By | ⇒ | wilsonge | |
Labels |
Added:
?
|
Thanks JM!
I found the same problem in Joomla 4.0 Beta 1
In /layouts/joomla/content/intro_image.php
the cose is:
<?php if ($images->image_intro_caption !== '') : ?>
<figcaption class="caption"><?php echo htmlspecialchars($images->image_intro_caption, ENT_COMPAT, 'UTF-8'); ?></figcaption>
<?php endif; ?>
My article have only Intro Image, without Caption
I suggest change the code with:
<?php if (!empty($images->image_intro_caption)) : ?>
<figcaption class="caption"><?php echo htmlspecialchars($images->image_intro_caption, ENT_COMPAT, 'UTF-8'); ?></figcaption>
<?php endif; ?>
Remove
$caption
variable and use the property directly, like before #20153. Also change caption check to compare against empty string (0
is a valid value for caption, IMO).