Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Now media is available, we should consider how to implement its image handling capabilities in Umami.
So far, Umami is using regular image fields to add images on content types. It results in not being able to reuse files.
Proposed resolution
Swap file field based image fields on Recipe and Article content types to use media image fields.
Look for potential places with existing content where we could reuse content between the two.
Remaining tasks
All the things.
User interface changes
TBD
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#93 | interdiff_91-93.txt | 952 bytes | shaal |
#93 | ootb-media-images-2954378-93.patch | 140.88 KB | shaal |
#91 | interdiff_90-91.patch | 1.74 KB | shaal |
#91 | ootb-media-images-2954378-91.patch | 140.95 KB | shaal |
#90 | interdiff_86-90.patch | 3.17 KB | shaal |
Comments
Comment #2
Eli-TOne potential place for image reuse is from the Chocolate Brownie recipe and the Vegan Chocolate article.
Comment #3
Eli-TComment #4
Eli-TComment #5
markconroy CreditAttribution: markconroy as a volunteer and at Annertech commented@Eli-T
I'm going to mark this as postponed for now, and let's revisit it asap once we get unhidden. I think this will make a great feature (and others are free to work on it in the meantime if they wish).
I am attaching the 'Umami new feature' tag to this item.
Comment #6
chr.fritschI built a first patch based on top of #2939594: Umami missing some Media "plumbing" found in Standard profile
This patch changes the image filed in the article and recipe to a media reference field. It also adjusts the data import to create media entities.
Comment #7
chr.fritsch#2939594: Umami missing some Media "plumbing" found in Standard profile landed, so move on here.
Comment #9
Eli-TJust to note as discussed the images on cards now link to media items rather than their respective articles/recipes - we need a solution for that.
Note that the recipe for brownies and the baking disasters currently use the same image - this patch creates seperate media entities, but instead should demonstrate reuse.
Comment #10
kjay CreditAttribution: kjay commentedConfirming our conversation in Slack. I vote that we remove the link from images and have the cards just display the image. Each card has at least the 'View article'/'View recipe' links and perhaps so many duplicate links on a card to the same location might be irritating to tab through.
Comment #11
Eli-T+1 to @kjay in #10 - remove the links, better for keyboard use as there are fewer redundant tabs.
Comment #12
chr.fritschSo, this new patch does:
Comment #13
Eli-TThanks @chr.fritsch!
The brownie image is now a shared media item as suggested in #9.
The links on the images are removed from cards as discussed in #10 and #11 when viewed on the front page, /articles, /recipes, and taxonomy based list pages such as /recipe-category/snack and /tags/supermarkets.
Manual A/B testing unpatched Umami and patch in #12 on the following pages as an anonymous looks identical:
However, converting these fields to media does introduce a second quick edit control for the media item behind the existing quick edit for the node. It is difficult to see as they are identically positioned but tabbing through the tab order will show it.
This shouldn't be a blocker here as it appears the quick edit for the node is displayed in front of the quick edit for the media item, and I think it is more likely the node edit is what a user would actually want. Sometimes it is displayed lower though - seems to be inconsistent on page refresh.
In fact, quick editing the media items might be a bad idea, as it is not as apparent that you could be changing the image used in multiple places.
Comment #14
chr.fritschI opened a follow-up for the contextual link issue #2983655: Contextual links are not displayed correctly
Comment #15
Eli-TAlso wrt patch in #12, \Drupal\demo_umami_content\InstallHelper::createMediaEntity() calls $this->entityTypeManager->getStorage() which can throw an exception we don't try/catch. If we did, we could recover an install that failed here that might otherwise fail.
At worst we should note that we leak the exception in the docblock.
Comment #16
chr.fritschHere is the code wrapped in a try/catch
Comment #17
Eli-TI have reviewed, applied and installed the patch in #17
I can confirm all my review points have been addressed, and the patch implements what we intend. I am happy the issue raised in #13 be addressed in follow up.
Therefore marking this as RTBC.
Comment #18
Gábor HojtsyI was surprised there was no image styles or anything removed from umami? Was umami using core shipped stuff or is that still equally needed/used for media given that the images would be one indirection point farther basically but still using those config?
Comment #19
Gábor HojtsyI was curious to see the UX of this as-is now. This is the UX after the patch for the media on a recipe. I did not screenshot the UX before since I did not have a site for that yet.
Comment #20
chr.fritschWe created two new view modes for media image, which are using now the already provided image styles from umami.
Comment #21
xjmComment #22
webchickHm. I'm *very* torn on this one.
I kind of lean towards postponing this patch until the Media Library + upload UI are both in (at least), or possibly even stable... because unless we do that, we are significantly degrading the UX of one of the major portions of the demo, and the point of the demo is to show people how frigging awesome Drupal is, in order to entice evaluators to start using it. And even if we added the Media Library in here to somewhat soften the blow, it's still vastly easier to use the existing Image UI (at the moment), and that is also what 99% of Drupal sites will use until that new functionality is marked stable. (So kinda feels like a bait-and-switch, "look at this awesome thing... that you can't actually use yet, hahaha!")
However, I am also open to being persuaded. :)
Comment #23
markconroy CreditAttribution: markconroy as a volunteer and at Annertech commentedGreat work here folks. Really looking forward to this being committed eventually.
I think I'm in the Webchick camp here. That 'Add image' interface is a terrible experience for first time users. What is says is: "we have reusable media, but at first glance you are going to need to remember the name of every media item on your site".
A simple file field is a much easier to understand experience.
To fix this we'd need a contrib module like inline_entity_form, which we obviously can't use or just wait it out like Webchick says until Upload UI is ready (I hadn't realised there was an Upload UI in progress, so that's good news!
I'll leave it at RTBC for now and let others chime in.
Comment #24
markconroy CreditAttribution: markconroy as a volunteer and at Annertech commentedJust thinking on this for the past hour, and it's a feature I'd love us to get into Umami asap, I wonder if we change the form display from an autocomplete field to a select list field would that help?
It would still mean that we have to create the media entities on another page (not ideal), but at least when trying to find one, you'd be presented with the list of them within the dropdown. This might not be suitable for a site with loads of images, but on first install, we are only talking about 12 or so images, so is manageable here. Then later when Upload UI is stable, we can switch to using that.
Comment #25
markconroy CreditAttribution: markconroy as a volunteer and at Annertech commentedTurns out my suggestion probably isn't good enough - the select list option doens't give the copy around it to say how to create a new media item (I guess since it won't have ajax to automatically pick it up without a screen refresh).
Comment #26
webchickYeah, multi-select select lists are in most cases an even worse UX than autocomplete, sadly. :\
The two patches in progress to make this whole thing better are #2962525: Create a field widget for the Media library module (select existing media through the Media Library) and #2938116: Allow media to be uploaded with the Media Library field widget (add new media from your hard drive). The second one looks unlikely to make it into 8.6, unfortunately, but the first one is more on the likely side, and that would eliminate the clunky autocomplete widget with a pretty graphical view of existing media to select from. So vastly better than the current UI in #19, but still clunkier than a simple file upload widget for adding new files.
I think there are a few things we need to sort out (and we might want to do so in some other issue):
1) What's the primary goal of Umami? Is it to put our best "Drupal" foot forward? Or is it a "tech demo" of everything core can do?
Personally, I would lean towards the first. Its target audience is new users of Drupal who want to get a decent idea of what Drupal does in a relatively short period of time, and we should sculpt the experience around that target audience.
2) Does it make sense to expose experimental functionality that is not recommended for production use in the demo?
This is a tricky one. There are arguments on both sides. On the one side, experimental functionality is where we're investing efforts in better UI/UX, and that's a big contributor to "best Drupal foot forward." OTOH if as an evaluator I'm trying to get a sense of what using Drupal day-to-day will be like, and I see this awesome Media Library functionality, then go to install my site "for reals" and find out that that's not recommended for production, I will feel mislead and frustrated.
Anyway, this is why my recommendation would be waiting until/unless at least #2962525: Create a field widget for the Media library module makes it in. Then we're introducing an arguably better media experience, at least in terms of selecting from existing media (albeit despite providing an unarguably worse experience for adding new media). In a perfect world, both of those patches would be in, and stable, and then it'd be silly at that point to still be using File/Image widgets. But that's probably 8.7, at best, at this point...
Comment #27
markconroy CreditAttribution: markconroy as a volunteer and at Annertech commentedOur general rule has been to use only stable core features, so if the media library is not stable yet, I think we should mark this issue as postponed.
Comment #28
xjmThis is at least NR rather than RTBC for #22 on. Whether to postpone it is ultimately a product decision, but postponing it on #2962525: Create a field widget for the Media library module seems like a reasonable choice to me. Thanks!
Comment #29
Eli-TFrom #22
Option 1) every time. And that means I think @webchick is right, whilst media reuse is cool, the user experience of the current UI is reduced, and until that's improved we should probably hold off.
Absolutely not.
I'll take a closer look at #2962525: Create a field widget for the Media library module and #2938116: Allow media to be uploaded with the Media Library field widget but looks like we're postponed on one if not both.
Comment #31
chr.fritschHere is an updated patch which uses the new media_library.
Question is, do we want to ship umami with an experimental module or do we have to wait until the media library is stable?
Comment #32
Eli-TAlas, umami with experimental modules is a no-go.
The purpose is to show what people can achieve with Drupal out of the box if they were to start using it today. We don't recommend people use experimental modules on production, so it is disingenuous for our out of the box demo to use them. Especially the group of people to whom OOTB is targeted - those unfamiliar with Drupal.
Which is a shame because this looks really good! On SimplyTest.me:
We might want to look at the spacing on the selection checkboxes.
There's also an odd mouse over effect on filenames greater than the width of the checkbox.
We have ended up with two media tabs on /admin/content
It would be good if the media names were converted back to real words rather than the file names.
It is great we've got so far on this ahead of the curve. Hopefully media library's path to stable is easy from hereon in.
(edit - finished final sentence)
Comment #33
Gábor HojtsyAt least a good thing about the media library is that it does not provide a data model, so it should get stable relatively fast. IMHO we can get this into 8.7 early in hopes media library gets stable in 8.7.
Comment #34
webchickLooks like this no longer applies to 8.6/8.7. Any chance of a re-rolled patch?
Comment #35
kjay CreditAttribution: kjay commentedHere's an updated patch that adjusts the config settings that are failing in 8.6.x due to a) content moderation being added and b) the many view mode changes I made for display settings support.
Hopefully I've done this right...
Comment #36
Eli-TPatch applies on 8.6.x and 8.7.x and testing on simplytest.me shows we have a working media library. Haven't tested the view modes or content moderation specifically.
Comment #37
JayKandariHi @kjay,
Tested locally,
✔️ Was able to successfully reuse media image in recipe & article contents.
✔️ Also tried creating new content - works perfectly.
[𐄂] I think the following fields also need to be updated to use media fields for block types fields as well.
1. Banner block » Banner image(field_banner_image)
2. Footer promo block » Promo image(field_promo_image)
and subsequently to be updated in
InstallHelper::importBlockContent()
method.Am I missing something?
Thanks!!
Comment #38
chr.fritschNice find @JayKandari
here is an updated patch.
Comment #40
chr.fritschFixing the config
Comment #41
samuel.mortensonHere's an issue to address the duplicate tab issue reported in #32: #2992056: [PP-1] The Media library doesn't modify the "media" view if installed in a profile.
The Umami profile could work around this by copy+pasting
media_library_install()
intodemo_umami_install()
, or rely on the issue getting fixed by 8.6.Comment #42
Eli-T+1 for the latter.
Comment #44
shaal(bad patch, please ignore)
Comment #45
shaalBy mistake, the previous patch included all config files.
Uploading a new clear patch.
[WIP]
Recipes are now using
field_media
instead offield_image
.Todo:
Add a process that adds multilingual images
Currently, images have a language but not related to the corresponding image in the other language.
Comment #47
Eli-TMoving version back to 8.8.x-dev as media library will not be stable until then at the earliest.
Comment #48
shaalFixed previous test error
Enabled media_library module
Comment #50
webchickIn addition to enabling media_library, we should also switch Recipes' form display to use Media library (vs. a select list) so we can show it off! :)
Comment #51
webchickAlso for some reason, all media items in the library seem to be showing up twice?
Comment #52
webchickAlso recommended (not as part of this patch necessarily) to enable Remote video on the field as well, and have one or two examples of YouTube/Vimeo content so we can show off oEmbed.
Comment #53
shaal@webchick thank you for reviewing it and providing the feedback.
This patch was made in a rush, as I thought we could have it for 8.7, but then realized we wouldn't because we'll have to wait for media_library to become stable in core first.
#50 - yes!
#51 - [WIP]
We need to have a process that adds multilingual images.
Currently, there's one image for each language, but they are not connected. (so you see double images) after this process it will work as expected.
#52 - it is already part of the roadmap for 8.8, set as an ambitious goal: #3047414: [META] Out of the box - 8.8 roadmap
Comment #54
shaal[WIP]
This patch replaces all image fields with media_image field and using media_library to select images for nodes.
This patch is still without the needed changes in the content import function, to import media images instead of images.
re #51 it is only a confusing display, not double content in the system. There's a special issue to fix it #3081587: Multilingual content is shown double in the media library view
No interdiff here because the patch from 5 months ago is very different.
Comment #55
Gayathri J CreditAttribution: Gayathri J commented#54
Hi shaal i am trying to apply this patch in 8.8 version umami site its not applied getting error please check this patch.
For reference I am adding the screenshot as well.
Comment #56
shaalHi @jgayathri
I don't know why weren't you able to apply the patch #54.
I attached here the screenshot of a successful patch I tried applying again today:
Comment #57
Gayathri J CreditAttribution: Gayathri J commentedHi @shaal patch applied successfully, "This patch replaces all image fields with media_image field" this was not effected for me in content type image field please check. I think so may be i am not understanding clearly what this patch was doing.
I attached screenshot please check.
Comment #58
shaalHi @jgayathri
From the screenshot you have provided, it seems that the patch was not applied on your machine.
I couldn't find you on Drupal slack (I am @shaal), I'll be happy to guide you through the patch process and make sure it works.
Comment #59
Gayathri J CreditAttribution: Gayathri J commentedI applied more patches why its not applied i dont know.
Thank you
Comment #60
shaal[WIP]
New in this patch: all recipes' images are imported as media images.
@TODO:
Add to recipe's 'media image' field the reference to the actual media image that was added.
(repeat for all other images used in Umami)
Comment #61
shaal[WIP]
New in this patch: all recipe images are using media images.
@TODO:
(repeat for all other images used in Umami)
Comment #62
shaal[WIP]
New in this patch: all article images are using media images.
@TODO:
(update block_banner and footer_promo to use media images)
Comment #63
shaal[WIP]
New in this patch: -
@TODO:
(update CSV of block_banner and footer_promo to use media images)
Comment #64
shaalTadaaaa.
This patch includes the latest changes needed:
footer_promo
andbanner_block
now import media image content, and the old image field is deletedComment #65
shaalI removed media image's default Name field mapping (to 'skip field), so the Spanish translation of the name of the images will be displayed in Spanish, instead of just the filename.
I found (a bug?) that without using the latest patch from #2992056: [PP-1] The Media library doesn't modify the "media" view if installed in a profile, the media listing page is broken -
only the table listing works, it's not possible to get the grid view, and the menu above displays 'media' twice.
When I apply the patch, the default media listing is grid, and 'media' doesn't appear twice on the menu.
Comment #68
shaalThe test failed because image referenced are not found after reinstalling demo_umami_content.
The reason is that the first imported media images are getting the same "ID" as in the CSV, but after uninstall+reinstalling they now get a new, different ID.
We should use the same method we used with saving the actual taxonomy IDs (vs. the original ID from the CSV)
Comment #69
shaalNow media images get the correct Drupal ID, and it is possible to reinstall
demo_umami_content
.Comment #70
alonaoneill CreditAttribution: alonaoneill at Hook 42 commented- Patch applied.
- Every recipe and article has an image. Edit recipe/article, and replace the existing image works. Block footer media image edit/replace the existing image works as well. When replacing images you get the Media Library, where before it was just upload an image right to that field, without the ability to reuse any previously uploaded images. Nothing is broken.
- The mobile/widescreen width looks good.
- Added screenshots.
Marking RTBCed
Comment #71
Gábor HojtsyDoes #3081587: Multilingual content is shown double in the media library view still happen?
Comment #72
shaal@Gábor, yes #3081587: Multilingual content is shown double in the media library view is still happening.
According to the conversation thread over there (#17 & #18) it's not a media_library's issue, but an older/deeper Drupal issue when presenting any multilingual content (like a simple Views list of nodes).
I'd love to hear your opinion & ideas on how it should be resolved.
Comment #73
phenaproximaI briefly discussed this, and #2992056: [PP-1] The Media library doesn't modify the "media" view if installed in a profile, with @webchick and @alexpott.
#2992056: [PP-1] The Media library doesn't modify the "media" view if installed in a profile is a very tough (and known) problem, but luckily Umami might be able work around it for the purposes of this patch. I haven't tested this, but according to @alexpott, what needs to happen is:
media
view, which should be complete and coherent, into Umami's optional config directory.The risk is that we run into #2922417: Profile provided configuration entities can have unmeetable dependencies, which would be...trouble.
Comment #75
shaal@phenaproxima thank you for the clear instructions. It worked!!
Note to self: follow instructions in #73 after #3081587: Multilingual content is shown double in the media library view is fixed.
Now /admin/content/media looks good again!
Comment #77
phenaproximaCrediting @alexpott for steering me in the right direction.
Comment #78
seanBIn addition to #75, I think the patch should also be updated if #2981105: Media Library should not modify the media view lands first with the instructions of #73.
Comment #79
webchickJust a report that I was testing this as part of testing #3081587: Multilingual content is shown double in the media library view and it worked GREAT! :D
Also spun off a "sister" issue to explore also integrating media with Umami's default WYSIWYG configuration: #3086965: Allow embedding media in CKEditor in Umami
Comment #80
webchickAw, shoot, spoke too soon; see #3081587-73: Multilingual content is shown double in the media library view.
This might just need some views re-exporting based on the fixes that have gone in in the past ~24 hours.
Comment #81
shaalAfter #2981105: Media Library should not modify the media view and #3081587: Multilingual content is shown double in the media library view got committed, I re-created views media config export as described in #73
Comment #83
Gayathri J CreditAttribution: Gayathri J at UniMity Solutions Pvt Limited commentedComment #84
shaalre-rolled #81
Comment #86
shaalAdding the missing 'match_limit' (got lost earlier during the re-roll process...)
Comment #87
webchickJust a heads up that #3082690: Mark Media Library as a stable core module is getting really close, and the patch there makes a ton of changes to Media Library's CSS / markup (moving it to other places in core as appropriate) to ensure better themeability. The flip-side is there might need to be work done on _this_ patch as a result, to ensure Media Library doesn't look overly simplistic and ugly in Umami.
Comment #88
shaal@webchick Thank you for the heads up, I tested #3082690: Mark Media Library as a stable core module together with this patch.
LGTM!
Comment #89
shaalI reviewed patch #88 together with @kjay and @markconroy
We went through the migration process changes and CSV changes (content no longer connects to an image file but to a media reference).
We used https://diffy.website and found 2 differences between current Umami and this patch.
You can download the full Diffy results here:
https://diffy-files.s3.amazonaws.com/2019/10/25/FixUmamisresponsivelayoutstyles2019-10-25-1593.tar.gz
Diffy Screenshots:
Recipes page is missing the hero image:
Homepage has an article view, that is displaying images 3x2 instead of a square (because of a missing view-mode):
Comment #90
shaalI added the hero image that was missing in recipes page.
Comment #91
shaalI added the missing Media-Image's view-mode
Square
and used the new view-mode inside Recipe'sCard Common Alt
view-mode.Comment #93
shaalI fixed test fail
removed from views.view.media.yml the line:
core: 8.x
I removed incorrect description from docblock in installHelper.php
Comment #94
markconroy CreditAttribution: markconroy as a volunteer and at Annertech commentedReviewed during a Google Hangout call yesterday with myself and @kjay and again just now after the issues discovered in that call were solved.
Great work @shaal. Thanks so much.
Comment #95
markconroy CreditAttribution: markconroy as a volunteer and at Annertech commentedTo the committers, this patch should only be committed _after_ #3082690: Mark Media Library as a stable core module is committed.
Comment #96
kjay CreditAttribution: kjay commented+1 for this being RTBC when Media Library is marked stable. Reviewed with @shaal and @markconroy. Media fields are now taking care of the images across nodes and blocks and the media library works as expected for selecting media. Responsive image styles are also setup as previously configured but now via the media display modes. Fantastic work @shaal and it's so exciting to see Media Library happening! :) :)
Comment #97
dixon_I tested the Umami demo profile with the new Workspaces module and it worked well until I applied the latest patch here. The hero block placement is breaking in workspaces.
I'll try to find some time to dig deeper into this. But after a quick look at the patch there seems to be things unrelated to Media entities that's changing that might be breaking things (e.g. field weights, Layout Builder stuff, etc.)?
Keeping this as RTBC until I have a patch or more credible proof of that it's actually this patch breaking block placements for Workspaces when used with Umami :)
Comment #98
shaal@dixon_ thank you for the feedback!
Can you please write the steps to replicate the problem you are seeing?
Comment #99
markconroy CreditAttribution: markconroy as a volunteer and at Annertech commented#3082690: Mark Media Library as a stable core module is now stable, so this can now be committed.
Comment #103
webchickI'd really like to get this into beta1, since it's such a huge improvement to the demo experience, so since Media Library is stable, and Workspaces is still beta (and thus not formally supported in Umami yet), and it's been a little over a week since dixon_'s feedback, I'm really hoping that committing this will not cause too much grief to the Workspaces team, and if it does, since Umami is "perma-experimental" hopefully we can get whatever bug fixes we need to sorted out quickly.
Committed and pushed to 9.0.x; 8.9.x; 8.8.x. SO MUCH EXCITEMENT!! Thanks so much for all the excellent work here, folks!
Comment #104
shaalCongratulations everyone!
re: #97, I created a followup ticket for Workspaces core module #3092549: Custom blocks with media are not being displayed
Comment #105
dixon_Congrats to the team here for getting this change in, it's awesome! :) We'll follow up in the issue @shaal created on the Workspace related issues. Thanks, and all good! :)
Wohoo for media images in Umami! 🎉