-
Notifications
You must be signed in to change notification settings - Fork 95
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
Lazy loading images in recipe list #413
Conversation
Codecov Report
@@ Coverage Diff @@
## master #413 +/- ##
===========================================
- Coverage 0.95% 0.92% -0.03%
- Complexity 401 410 +9
===========================================
Files 13 13
Lines 1262 1301 +39
===========================================
Hits 12 12
- Misses 1250 1289 +39
Flags with carried forward coverage won't be shown. Click here to find out more.
|
fd77f29
to
f7e20fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general. I have not yet tested it but I assume it is working.
@@ -748,7 +752,7 @@ public function addRecipe($json) { | |||
$thumb_image = new Image(); | |||
$thumb_image->loadFromData($full_image_data); | |||
$thumb_image->fixOrientation(); | |||
$thumb_image->resize(128); | |||
$thumb_image->resize(256); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will default the thumb image size to 256x256. We should make sure, this is no problem as the old files are still 128x128.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to put this out for discussion. Actually this change doesn’t make too much sense, since currently the images are shown in the lists in 105px by 105px - so 128 is more sensible in the sense that is less data to be transfered. However, there seems to be the need for larger thumbnails (#406). We could also keep the 128px thumbnail thumb.jpg
and create a 256x256 version as thumb@2x.jpg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not consider this too much of a problem to use 256x256. It is only a few kB per recipe.
Before this gets merged, I’d prefer to have someone test it :) |
f7e20fc
to
1d5ac91
Compare
I just checked with an existing (dev) version. I found one issue yet open: The pre-existing images are not rerendered for the thumb16. So while the main images are loading, all recipes that were imported before the merge are showing a fork and knife in blurred version. I would consider this OK for now as it should not cause trouble as it is shown only a very limited amount of time. We should however prepare a migration step in #340 to make everything consistent. As this can be tackled later easily, I suggest merging. @sam-19 please give your opinion. If something breaks, we can reverse that later without issues. |
4b0a841
to
38b58fb
Compare
@christianlupus I added a check if thumb16 is present and recreate the thumbnails if this is not the case. |
61b8f8c
to
4a7a78b
Compare
I also added the lazy-loading to the search results and category pages. |
I'm not familiar with the Lozad library, but the general idea seems good to me. I just wonder if the recipe links (in index and search results) should have been converted into a component of its own. This could possibly save some trouble and iteration, especially if recipe lists are are used in more places in the future. Then again, every new component increases complexity a bit, so it's probably not worth it yet. There is one import line ending in a semi-colon in LazyPicture.vue, though :) |
Do you mean the complete tiles? I.e., Image plus title? I also thought about this and I guess that is a good idea. Especially if we want to change the layout at some point (e.g. square tiles with the image filling the tile and the title as an overlay) or even simply adding more information (category, number of stars, sharing status, cookbook name (if there are multiple at some point), etc.) to it. However, I don’t think this is the right PR to do this.
I’ll remove this! |
Added lozad lazy loading module Signed-off-by: Sebastian Fey <info@sebastianfey.de>
…x128 thumbnail for recipes Signed-off-by: Sebastian Fey <info@sebastianfey.de>
Signed-off-by: Sebastian Fey <info@sebastianfey.de>
Signed-off-by: Sebastian Fey <info@sebastianfey.de>
Signed-off-by: Sebastian Fey <info@sebastianfey.de>
15668c2
to
e538271
Compare
Signed-off-by: Sebastian Fey <info@sebastianfey.de> Signed-off-by: Christian Wolf <github@christianwolf.email>
Signed-off-by: Sebastian Fey <info@sebastianfey.de>
Signed-off-by: Sebastian Fey <info@sebastianfey.de>
e538271
to
c538274
Compare
Lazy loading images in recipe list
I was too quick with the merging, unfortunately. I had to revert and emerge to get the checks done right. Correct merge commit is 66f8023. |
This PR provides lazy loading of the images as discussed in #409 (currently only in the AppIndex) and also introduces a higher-resolved thumbnail as discussed in #406 (to be discussed).
The thumbnails are only loaded when they enter the viewport using the Intersection Observer API. The images are rendered/loaded in the following way
This proposal needs to be tested and checked.
Closes #409
CC: @sam-19