NPM Resource Changed ? Pending

User tests: Successful: Unsuccessful:

avatar dgrammatiko
dgrammatiko
3 Jan 2022

Pull Request for Issue #36533 [Solves 1/3 reported problems, the thumbs and the streaming/paginated response are still valid... ].

Summary of Changes

  • Add and intersectionObserver so the browser won't try to fetch every image in the list view (only the ones that are visible)

Testing Instructions

  • Apply this PR and run npm ci or d/l the package from github
  • navigate to different subfolders in the images folder
  • Open the browser inspector, select the Network tab and then the img tab. As you scroll in the list view more images will appear both in the list view and in the network/img tab. The Network/img should have less images that the total amount of images in the list (assuming the viewport is not revealing all the images and you haven't scrolled to the end of the list)

Actual result BEFORE applying this Pull Request

All images fetched immediately

Expected result AFTER applying this Pull Request

Images are fetched as they enter the viewport

Documentation Changes Required

No

Ping @laoneo @Fedik @crystalenka

avatar dgrammatiko dgrammatiko - open - 3 Jan 2022
avatar dgrammatiko dgrammatiko - change - 3 Jan 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 3 Jan 2022
Category Administration com_media NPM Change JavaScript
avatar dgrammatiko dgrammatiko - change - 3 Jan 2022
Labels Added: NPM Resource Changed ?
87d01f8 3 Jan 2022 avatar dgrammatiko CS
avatar laoneo
laoneo - comment - 3 Jan 2022

Should we not just add the loading="lazy" attribute to the image tag as the dimensions are available for the images. We should use the platform as much as possible said once a Joomla JS developer (can't remember his name ? ).

avatar crystalenka
crystalenka - comment - 3 Jan 2022

Should we not just add the loading="lazy" attribute to the image tag as the dimensions are available for the images. We should use the platform as much as possible said once a Joomla JS developer (can't remember his name ? ).

There are no img tags in the media manager currently - all images are loaded as background images of div elements.

avatar laoneo
laoneo - comment - 3 Jan 2022

What is the benefit of loading them as background images?

avatar dgrammatiko
dgrammatiko - comment - 3 Jan 2022

We should use the platform as much as possible said once a Joomla JS developer (can't remember his name ? ).

This sounds obnoxious. Why would you ever want to use the browser's provided APIS instead of building them again and having a gazillion of bugs?

Joke apart the loading=lazy is an attribute for the img element and as @crystalenka already mentioned the design is asking for a style="background-image: ..."

What is the benefit of loading them as background images?

No alt (obviously this is an a11y problem) and it was easier to style/append the edit buttons/checkbox on top (?)

avatar crystalenka
crystalenka - comment - 3 Jan 2022

I have absolutely no idea, it seems inefficient to me but I'm not sure. Just commenting why lazy loading wouldn't work as the media manager works now.

avatar crystalenka
crystalenka - comment - 3 Jan 2022

No alt (obviously this is an a11y problem) and it was easier to style/append the edit buttons/checkbox on top (?)

How wonderful it would be to manage alt text globally! But this is beyond the scope of this issue/pr, haha.

I am happy to help style the edit buttons over the top of inline images if that is more efficient/a necessary change.

avatar joomla-cms-bot joomla-cms-bot - change - 3 Jan 2022
Category Administration com_media NPM Change JavaScript Administration com_media NPM Change JavaScript Repository
avatar dgrammatiko
dgrammatiko - comment - 3 Jan 2022

Ok, switched to the image tag and used the loading attribute. The styling is a bit of but some object-fit: contain; or something similar should get us back to the previous state (design-wise). @crystalenka @laoneo

Screenshot 2022-01-03 at 18 30 34

avatar dgrammatiko dgrammatiko - change - 3 Jan 2022
Title
[4.0] Use intersectionObserver for Media Manager images list
[4.0] Switch div to img and use the loading attr. [Media Manager images list]
avatar dgrammatiko dgrammatiko - edited - 3 Jan 2022
avatar crystalenka
crystalenka - comment - 3 Jan 2022

I'll test this and check styling later today or tomorrow. Thank you!!

avatar laoneo
laoneo - comment - 3 Jan 2022

I first test shows the attributes loading, width and height in the image. But they are loaded initially in the network tab on FF and chrome.

Additionally has the image container not the same dimensions as the folders:
image

avatar dgrammatiko
dgrammatiko - comment - 3 Jan 2022

Additionally has the image container not the same dimensions as the folders:

Yes, switching to the image element needs some scss fixes

I first test shows the attributes loading, width and height in the image. But they are loaded initially in the network tab on FF and chrome.

If you roll to 87d01f8 you'll see that the intersectionObserver is a better fit here. The reason is that there's something weird with the zoom-in/out functionality that triggers the browser to always consider more images in the viewport than what's actually there. Didn't spend any time figuring out what's triggering this (container or item size, or anything else)

avatar laoneo
laoneo - comment - 3 Jan 2022

The reason is that there's something weird with the zoom-in/out functionality that triggers the browser to always consider more images in the viewport than what's actually there. Didn't spend any time figuring out what's triggering this (container or item size, or anything else)

Pretty sure you can fix this ?

d903326 3 Jan 2022 avatar dgrammatiko cs
avatar crystalenka
crystalenka - comment - 4 Jan 2022

I have tested this item successfully on d903326

If you add the following CSS rules to .image-cropped it fixes the styling issue in modern browsers:

aspect-ratio: 1/1;
object-fit: contain;

Aspect ratio is supported in most recent releases of most modern browsers (https://caniuse.com/?search=aspect-ratio), I'm not sure what J4 is supposed to support but if necessary I can do this a different way. This is just the most future-proofed way to do it.


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

avatar crystalenka crystalenka - test_item - 4 Jan 2022 - Tested successfully
avatar Quy Quy - change - 4 Jan 2022
Title
[4.0] Switch div to img and use the loading attr. [Media Manager images list]
[4.1] Switch div to img and use the loading attr. [Media Manager images list]
avatar Quy Quy - edited - 4 Jan 2022
avatar Quy
Quy - comment - 11 Jan 2022

SVG not displaying correctly.

36550-svg

<img class="image-cropped" src="undefined?1641936364457" alt="brand-large.svg" loading="lazy" width="0" height="0">

avatar infograf768
infograf768 - comment - 12 Jan 2022

@Quy
Same result as you in Firefox and Chrome
Screenshot 2022-01-12 at 10 53 03

Same error but different display in Safari:

Screenshot 2022-01-12 at 10 51 05

avatar richard67 richard67 - change - 1 Feb 2022
Title
[4.1] Switch div to img and use the loading attr. [Media Manager images list]
[4.2] Switch div to img and use the loading attr. [Media Manager images list]
avatar richard67 richard67 - edited - 1 Feb 2022
avatar richard67 richard67 - change - 1 Feb 2022
Labels Added: ?
Removed: ?
avatar dgrammatiko
dgrammatiko - comment - 2 Feb 2022

@laoneo will take over this one

avatar dgrammatiko dgrammatiko - change - 2 Feb 2022
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2022-02-02 20:22:10
Closed_By dgrammatiko
avatar dgrammatiko dgrammatiko - close - 2 Feb 2022
avatar laoneo
laoneo - comment - 3 Feb 2022

Please test #36930 which is the followup on this one.

Add a Comment

Login with GitHub to post a comment