Skip to content

Conversation

@dgrammatiko
Copy link
Contributor

Pull Request for Issue #36533 [Solves no 2 of the 3 reported problems, the thumbs ].

This is still a draft as it is missing the UI for regenerating the thumbs recursively (in the options of the local adapter)

Summary of Changes

  • Generate thumbs for the Media manager

Testing Instructions

Actual result BEFORE applying this Pull Request

Media manager loads a thumb

Expected result AFTER applying this Pull Request

Media manager Loads the full image

Documentation Changes Required

From a code point of view, the decision was to place the thumbs in a subfolder of the media folder called cache_mm
The reason that I didn't reuse the existing cache folder is simple: Joomla cleans that folder on each update and we WANT the thumbs to persist on updates (they are static files so PHP/JS/CSS/db changes are largely irrelevant).

@dgrammatiko dgrammatiko marked this pull request as draft January 3, 2022 20:10
@brianteeman
Copy link
Contributor

brianteeman commented Jan 3, 2022

/me still waits for the day when there are no path issues in one of your pr

<div class="image-cropped" style="background-image: url(&quot;http://localhost/joomla-cms/C:/htdocs/joomla-cms/images/sampledata/parks/landscape/120px_pinnacles_western_australia.jpg?1641240738875&quot;);"></div>

@dgrammatiko
Copy link
Contributor Author

/me still waits for the day when there are no path issues in one of your pr

FWIW this is not the subfolder issue but me modifying the path string in a UNIX way (obviously fails for fat/ntfs)

@brianteeman
Copy link
Contributor

No its not a unixfs thing you are mixing up the JPATH_ROOT and the uri:root

I doubt it would work on any filesystem

JPATH_ROOT : C:\htdocs\joomla-cms
Uri::root() : http://localhost/joomla-cms/

@dgrammatiko
Copy link
Contributor Author

@laoneo any thoughts here?

@brianteeman
Copy link
Contributor

still no joy

@laoneo
Copy link
Member

laoneo commented Jan 3, 2022

I did something similar in DPMedia. But made resized only 10 images per request. The other ones I do serve with with a placeholder image. On large image folders it takes too much resources on shared hosting and ended up with broken thumbnails.

@brianteeman
Copy link
Contributor

the thumbnails are now created and used

think you need to check the code that creates the thumbnails as the dimensions are ok but the files are big - some are even bigger than the original

image

@brianteeman
Copy link
Contributor

PS if we have thumbnails do we still need lazyload?

@dgrammatiko
Copy link
Contributor Author

PS if we have thumbnails do we still need lazyload?

Yes, the thumbnails fix the bandwidth problem, the lazyloading fixes the UI responsiveness (eg view the file thumbs quicker).
Still the pagination or streaming is missing to fix the enormous lists (the actual number might not be that big on a cheap server). As I said this is a 3 fold problem...

@joomla-cms-bot joomla-cms-bot added the Language Change This is for Translators label Jan 4, 2022
@Fedik
Copy link
Member

Fedik commented Jan 4, 2022

The reason that I didn't reuse the existing cache folder

Please use /media/cache/com_media as cache.
On update Joomla will clear a root /cache and should not clear /media/cache, otherwise it a bug to me.

Other thing: have to ensure a thumbnail exists (and create it if not) on request, not only while upload.
This way it will be easy to refresh whole cache in case of any failure.

@dgrammatiko
Copy link
Contributor Author

dgrammatiko commented Jan 4, 2022

Other thing: have to ensure a thumbnail exists (and create it if not) on request,

It's already like that

otherwise it a bug to me.

The last time I've checked, Joomla clears the media cache but I can change it no debate here

EDIT: @Fedik I switched the cache folder to 'media/cache/com_media/thumbs/' . $this->filePath where $this->filePath is the local adapter, eg images.
Someone needs to confirm that Joomla is not emptying the media/cache folder on updates otherwise this is completely wrong, an update should not invalidate the thumbnails...

@dgrammatiko dgrammatiko marked this pull request as ready for review January 4, 2022 19:24
@dgrammatiko
Copy link
Contributor Author

Missing / before the filename.

Is that for the tests or on your local machine?

Signed-off-by: dgrammatiko <[email protected]>
@Quy
Copy link
Contributor

Quy commented Jan 16, 2022

Testing locally with a new install.

missing-slash

@dgrammatiko
Copy link
Contributor Author

@Quy fetch the latest changes and try again (it's hard to debug something that's not replicable locally)

Signed-off-by: dgrammatiko <[email protected]>
@Quy
Copy link
Contributor

Quy commented Jan 16, 2022

Sorry no go. Thumbnails are generated. Just missing / before the filename in the thumbnail URL.

Signed-off-by: dgrammatiko <[email protected]>
@Quy
Copy link
Contributor

Quy commented Jan 16, 2022

It is ok in the main folder but not in subfolders. Missing / after banners folder.

http://localhost/Joomla_4.1.0-dev+pr.36552-Development-Full_Package/media/cache/com_media/thumbs/images/bannersosmbanner1.png?1642371757494

Signed-off-by: dgrammatiko <[email protected]>
Signed-off-by: dgrammatiko <[email protected]>
Signed-off-by: dgrammatiko <[email protected]>
Comment on lines +275 to +278
if (!is_dir(dirname($thumbPaths['fs'])))
{
mkdir(dirname($thumbPaths['fs']), 0755, true);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be removed since it is checked/created here?

if (!is_dir($thumbsFolder) && (!is_dir(\dirname($thumbsFolder)) || !@mkdir($thumbsFolder)))

{
$dir = JPATH_ROOT . '/media/cache/com_media/thumbs/' . $this->filePath;

if (!is_dir($dir))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need it only when you writing a thumbs, it does not need in constructor


if (!is_dir(dirname($thumbPaths['fs'])))
{
mkdir(dirname($thumbPaths['fs']), 0755, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace all use of mkdir() to Folder::create(), this will create a folder with all subfolders recursively.

@dgrammatiko
Copy link
Contributor Author

@Quy @Fedik and everyone else involved here: first of all thanks for all the code reviews, feedback and testing but we're too late for 4.1...
This needs to be postponed to 4.2 or if the maintainers feel that it could go on a patch on a 4.1.x
That said I won't be the one driving this feature so feel free to fork the work done here and patch anything still missing, buggy, etc

Thanks! ☮

@dgrammatiko dgrammatiko changed the base branch from 4.1-dev to 4.2-dev January 24, 2022 10:41
@Quy Quy added PR-4.2-dev and removed PR-4.1-dev labels Jan 24, 2022
@richard67 richard67 changed the title [4.1] Local adapter thumbnails [4.2] Local adapter thumbnails Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants