? ? Pending

User tests: Successful: Unsuccessful:

avatar infograf768
infograf768
20 May 2018

Summary of Changes

Preventing Notices for articles image_intro_caption and image_fulltext_caption when these fields are empty

Testing Instructions

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.

avatar infograf768 infograf768 - open - 20 May 2018
avatar infograf768 infograf768 - change - 20 May 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 20 May 2018
Category Layout
avatar SharkyKZ
SharkyKZ - comment - 20 May 2018

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).

<?php if ($images->image_intro_caption !== '') : ?>
	<figcaption class="caption"><?php echo htmlspecialchars($images->image_intro_caption); ?></figcaption>
<?php endif; ?>
avatar Bakual
Bakual - comment - 20 May 2018

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.

avatar laoneo
laoneo - comment - 20 May 2018

I have tested this item successfully on 5814d62


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20503.

avatar laoneo laoneo - test_item - 20 May 2018 - Tested successfully
avatar laoneo
laoneo - comment - 20 May 2018

Just saw the comments, will retest when the suggested changes are done.

avatar infograf768 infograf768 - change - 20 May 2018
Labels Added: ?
avatar infograf768
infograf768 - comment - 20 May 2018

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.

avatar Quy
Quy - comment - 20 May 2018

I have tested this item successfully on 906924a


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20503.

avatar Quy Quy - test_item - 20 May 2018 - Tested successfully
avatar Quy
Quy - comment - 20 May 2018

I have tested this item successfully on 37426a6


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20503.

avatar Quy Quy - test_item - 20 May 2018 - Tested successfully
avatar SharkyKZ SharkyKZ - test_item - 20 May 2018 - Tested successfully
avatar SharkyKZ
SharkyKZ - comment - 20 May 2018

I have tested this item successfully on 37426a6


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20503.

avatar Quy Quy - change - 20 May 2018
Status Pending Ready to Commit
avatar Quy
Quy - comment - 20 May 2018

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20503.

avatar wilsonge wilsonge - close - 21 May 2018
avatar wilsonge wilsonge - merge - 21 May 2018
avatar wilsonge wilsonge - change - 21 May 2018
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: ?
avatar wilsonge
wilsonge - comment - 21 May 2018

Thanks JM!

avatar Razzo1987
Razzo1987 - comment - 4 Jun 2020

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; ?>

Add a Comment

Login with GitHub to post a comment