- Issue created by @Grimreaper
- Merge request !47Issue #3484282 by grimreaper: WIP: Media source plugin → (Merged) created by Grimreaper
- 🇫🇷France Grimreaper France 🇫🇷
I just thought of something about thumbnail.
As it creates a file entity which points to the SVG file in the library, if the file entity is deleted (for any reason: media deleted, so usage drops to 0, manual deletion, etc.), will it delete the SVG file in the icon library?
I need to check that and also test if Fontawesome does not have the same problem.
- 🇫🇷France Grimreaper France 🇫🇷
MariaDB [drupal]> SELECT * FROM file_managed; +-----+--------------------------------------+----------+------+-------------------+------------------------------------------------------+---------------+----------+--------+------------+------------+ | fid | uuid | langcode | uid | filename | uri | filemime | filesize | status | created | changed | +-----+--------------------------------------+----------+------+-------------------+------------------------------------------------------+---------------+----------+--------+------------+------------+| 5 | 5f75ac1d-3c39-45ed-9217-49e9a63fcc4a | en | 1 | square-gitlab.svg | /libraries/fontawesome/svgs/brands/square-gitlab.svg | image/svg+xml | NULL | 1 | 1730297429 | 1730297429 | | 10 | acf3c1fc-d063-4bd9-a989-2193e4984dc1 | en | 1 | gitlab.svg | libraries/fontawesome/svgs/brands/gitlab.svg | image/svg+xml | 1055 | 1 | 1730713012 | 1730713012 | +-----+--------------------------------------+----------+------+-------------------+------------------------------------------------------+---------------+----------+--------+------------+------------+
So I have tested with the plugin from the issue.
Has the URI is something like "/libraries/fontawesome/svgs/brands/square-gitlab.svg" with a slash at the beginning, Drupal does not detect its size.
And when I delete the media the file is not deleted but if I trigger manually the file entity deletion, then:
- app/core/lib/Drupal/Core/File/FileSystem.php::delete:... // Return TRUE for non-existent file as the current state is the intended // result. if (!file_exists($path)) { return TRUE; } ...
Does not detect the file so it is not deleted.
I tried with the fontawesome module media source plugin. And with it, the thumbnail URI is like "libraries/fontawesome/svgs/brands/gitlab.svg" without slash at the beginning so Drupal detect the file size, and same when I delete the media, the URI is not deleted automatically.
And if I manually delete the file entity then I got:
Warning: unlink(libraries/fontawesome/svgs/brands/github.svg): Permission denied in Drupal\Core\File\FileSystem->unlink() (line 118 of core/lib/Drupal/Core/File/FileSystem.php).
So, Drupal really tried to delete the file and it was only system file permissions which prevented the deletion.
So, I guess for the thumbnail, I think we should copy the file into the public stream wrapper and then use this copy.
- First commit to issue fork.
- 🇫🇷France Grimreaper France 🇫🇷
MR updated.
Please tell me if this method to get thumbnail is ok. I didn't find a way to get it simpler.
I left 2 todos to open discussion.
When feedbacks will be ok I will update tests.
- 🇫🇷France Grimreaper France 🇫🇷
CI jobs in failure are not related to the changes in the MR.
Back to needs review.
-
mogtofu33 →
committed 37ec9b98 on 1.0.x authored by
grimreaper →
Issue #3484282 by grimreaper, mogtofu33: Media source plugin
-
mogtofu33 →
committed 37ec9b98 on 1.0.x authored by
grimreaper →
Automatically closed - issue fixed for 2 weeks with no activity.