? ? Success

User tests: Successful: Unsuccessful:

avatar Bakual
Bakual
12 Apr 2018

Pull Request to remove the legacy caption.js

Summary of Changes

Removes the JHtml::_('behavior.caption') calls, the method itself and its JS files and test code.

Testing Instructions

  • Make sure caption.js isn't requested anymore in any pageview
  • Captions should work as before because we actually moved to use figure and figcaption long ago. The JS was kept and loaded for B/C reasons with existing old articles.

Expected result

Captions work as before

Actual result

Captions work as before

Documentation Changes Required

Mark the method as deprecated in 3.9 (I can do that PR) and in the docs.

avatar Bakual Bakual - open - 12 Apr 2018
avatar Bakual Bakual - change - 12 Apr 2018
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 12 Apr 2018
Category Front End com_contact com_content com_newsfeeds Libraries JavaScript Unit Tests
avatar dgrammatiko
dgrammatiko - comment - 12 Apr 2018

We need to remove the related js test: https://github.com/joomla/test-javascript/tree/master/src/caption

I'll do a PR for that (but I still have to convert at least one basic script test there as an example, so give me some time for this...)

avatar brianteeman
brianteeman - comment - 12 Apr 2018

Captions should work as before because we actually moved to use figure and figcaption long ago. The JS was kept and loaded for B/C reasons with existing old articles.

New articles created in 3.8 do not use figure and figcaption. So what is the plan to convert all articles on upgrade

avatar dgrammatiko
dgrammatiko - comment - 12 Apr 2018

@brianteeman are you referring to intro/full image or the images in the full text field (editor)?

avatar brianteeman
brianteeman - comment - 12 Apr 2018

intro/full is the only one that has caption

avatar dgrammatiko
dgrammatiko - comment - 12 Apr 2018

So we can update their jLayouts to use figcaption/figure tags

avatar dgrammatiko
dgrammatiko - comment - 12 Apr 2018

This I think should be ok

<?php if (isset($images->image_fulltext) && !empty($images->image_fulltext)) : ?>
	<?php $imgfloat = empty($images->float_fulltext) ? $params->get('float_fulltext') : $images->float_fulltext; ?>
	<figure class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image">
		<img src="<?php echo htmlspecialchars($images->image_fulltext); ?>" alt="<?php echo htmlspecialchars($images->image_fulltext_alt); ?>" itemprop="image"/>
		<?php if ($images->image_fulltext_caption) :
			echo '<figcaption class="caption">'
					. htmlspecialchars($images->image_fulltext_caption)
				. '</figcaption>';
		endif; ?>
	</figure>
<?php endif; ?>
avatar Bakual
Bakual - comment - 12 Apr 2018

@brianteeman Since J3.2.2 the image button in the editor should create figure and figcaption elements. My PR back then was #2664 and when I tested it now it still works this way.
Of course, articles created before that time would have "broken" captions as long as you don't load a replacement JS (eg using a plugin) or edit the articles to use figure. There is no way we can do that on updates.
I assumed we had changed the into/fullimages layouts as well, but apparently that was never done? Of course that then needs to be done in this PR as well. No need to update anything on the content for this.

Or do I miss something?

avatar brianteeman
brianteeman - comment - 12 Apr 2018

I assumed we had changed the into/fullimages layouts as well, but apparently that was never done? Of course that then needs to be done in this PR as well. No need to update anything on the content for this.

yes that is all that needs to be done

avatar dgrammatiko
dgrammatiko - comment - 12 Apr 2018

My PR back then was #2664 and when I tested it now it still works this way.

Well it's not working like that anymore with the new media manager. ?
We need to fix that ASAP

avatar Bakual Bakual - change - 12 Apr 2018
Labels Added: ? ?
avatar joomla-cms-bot joomla-cms-bot - change - 12 Apr 2018
Category Front End com_contact com_content com_newsfeeds Libraries JavaScript Unit Tests Front End com_contact com_content com_newsfeeds Layout Libraries JavaScript Unit Tests
avatar Bakual
Bakual - comment - 12 Apr 2018

Adjusted the layouts for the intro and full image to use figure and figcaption tags.
The figure is always added, regardless if there is a caption or not.

@brianteeman I've read that the figure element should have an aria role=group if there is a caption included. I've added that one. Maybe you can verify if that is correct.

avatar Bakual
Bakual - comment - 12 Apr 2018

@brianteeman I can't say I understand everything written there. My knowledge about accessibility is quite limited. I got the part about the role=group from a german site (https://wiki.selfhtml.org/wiki/HTML/Textstrukturierung/figure).
What I got from your article is that the caption should be before the image, and in fact with the caption.js currently it's like that as well. So I moved that around.

avatar laoneo
laoneo - comment - 9 May 2018

@brianteeman are the changes ok regarding accessibility?
@dgrammatiko can you fix the related js tests from the testing repo?
@Bakual can you fix the conflicts here that we can move to the next step?

avatar brianteeman
brianteeman - comment - 9 May 2018

better to ask the accessibility team than me

avatar joomla-cms-bot joomla-cms-bot - change - 9 May 2018
Category Front End com_contact com_content com_newsfeeds Libraries JavaScript Unit Tests Layout Front End com_contact com_content com_newsfeeds Layout Libraries JavaScript
avatar Bakual
Bakual - comment - 9 May 2018

Rebased PR and fixed the conflict

avatar chmst
chmst - comment - 15 May 2018

@Bakual goupin roles are used to identify related form controls, so I do not see a necessity in figure/figcaption

avatar Bakual
Bakual - comment - 15 May 2018

Ok, I'll remove that part then. Makes code simpler ?

avatar Bakual Bakual - change - 15 May 2018
Labels Removed: ?
avatar laoneo
laoneo - comment - 18 May 2018

Opened a pr joomla/test-javascript#7 in the testing repo to remove the caption.js tests. Once this is merged, we can merge this one here too.

avatar laoneo
laoneo - comment - 18 May 2018

Once #20449 is merged, the JS tests will always be fetched from the correct branch instead of the latest version.

avatar laoneo laoneo - change - 18 May 2018
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-05-18 11:02:51
Closed_By laoneo
Labels Added: ?
avatar laoneo laoneo - close - 18 May 2018
avatar laoneo laoneo - merge - 18 May 2018
avatar laoneo
laoneo - comment - 18 May 2018

Great work, thanks @Bakual!

avatar Bakual
Bakual - comment - 18 May 2018

Follow up PR to deprecate it in J3: #20451

avatar infograf768
infograf768 - comment - 20 May 2018

Beware #20503

avatar infograf768
infograf768 - comment - 20 May 2018

BTW, I do not understand what is behind the idea that the caption should be before the image.
My test show that with this template it displays above the image, which is a nonsense.

avatar chmst
chmst - comment - 20 May 2018

@infograf768 it is more a matter of taste but figcaption can be used above or below (or both).

avatar infograf768
infograf768 - comment - 20 May 2018

@chmst
I understand it is possible to display the caption above or below with figcaption but, nevertheless, the most common usage is below.
Will make another PR after #20503 is merged.

avatar dgrammatiko
dgrammatiko - comment - 20 May 2018

!Idea: let's have some options in the backend for the placement of the caption...

PS. I'm joking ?

Add a Comment

Login with GitHub to post a comment