Problem/Motivation
On a 8.7.7 site I'm building, I'm using core media's video bundles, pointing to YouTube.
If I inspect the filesystem for the actual thumbnails downloaded by YouTube, I see stuff like this:
% identify *
1V7gFNbwKdw.jpg JPEG 1280x720 1280x720+0+0 8-bit sRGB 102KB 0.000u 0:00.009
4b5n5PVdHpI.jpg JPEG 1280x720 1280x720+0+0 8-bit sRGB 104KB 0.000u 0:00.000
55n7BFvNqFQ.jpg JPEG 1280x720 1280x720+0+0 8-bit sRGB 32.2KB 0.000u 0:00.000
R0gFH3_sMGw.jpg JPEG 1280x720 1280x720+0+0 8-bit sRGB 188KB 0.000u 0:00.000
S3sdd1i9pbQ.jpg JPEG 1280x720 1280x720+0+0 8-bit sRGB 399KB 0.000u 0:00.000
lzkW7ngYvQo.jpg JPEG 320x180 320x180+0+0 8-bit sRGB 10.4KB 0.000u 0:00.000
n1X73ZyQroE.jpg JPEG 1280x720 1280x720+0+0 8-bit sRGB 127KB 0.000u 0:00.000
pFrani050Zs.jpg JPEG 320x180 320x180+0+0 8-bit sRGB 6.08KB 0.000u 0:00.000
However, {media_field_data} has a totally different idea:
mysql> SELECT mid, thumbnail__width, thumbnail__height FROM media_field_data WHERE bundle = 'video' LIMIT 5;
+-----+------------------+-------------------+
| mid | thumbnail__width | thumbnail__height |
+-----+------------------+-------------------+
| 1 | 180 | 180 |
| 5 | 180 | 180 |
| 15 | 180 | 180 |
| 16 | 180 | 180 |
| 17 | 180 | 180 |
+-----+------------------+-------------------+
5 rows in set (0.00 sec)
Thanks to image_preprocess_image_style()
, this results in thumbnail markup like so:
<img src=".../sites/default/files/styles/320x180_small/public/video_thumbnails/S3sdd1i9pbQ.jpg?itok=L8Ug7t3z" width="180" height="180" alt="" typeof="foaf:Image" class="image-style-_20x180-small">
Those width and height attributes are bogus, since the metadata in the DB thinks those are the dimensions of the thumbnail. This results in unnecessarily small thumbnails that don't truly respect the image style as I defined it.
Proposed resolution
Record accurate dimensions for the thumbnail files in the media entity metadata stored in the DB.
Remaining tasks
- Figure out why these dimensions are bogus in the DB and fix it.
- Add test coverage about this problem.
- Review
- RTBC
- Commit
User interface changes
Media thumbnails will know their accurate size/aspect ratio, hopefully resulting in better looking UI in places where media thumbnails are being displayed.
API changes
Hopefully none.
Data model changes
None.
Release notes snippet
TBD