Option for tag1 AND tag2 AND tag3 in Media Library Widget?
I am considering Cloudinary for a large replatforming effort with a lot of structured data on the media in the project.
Is there a way to configure the media library widget to do an AND search instead of an OR search on tags in the 'Advanced Query' section?
So if I select 3 tags on our media the results are all 3 tags? IE if I select three tags of size-8, leather, & loafers, I don't see size-10, leather, boots in the results?
Obviously, this can be done with the Query Builder, but this is a lot of extra keystrokes that will cost my team dozens of hours:
(tags = "size-8" AND tags = "leather" AND tags = "loafers")
______
Note that the 'Context' section of the Advanced Search feature has a dropdown for AND or OR. A similar UX for tags would be great!
Thanks!
-
Hi Ada,
Thanks so much for reaching out.
Yes, this is possible. When you call the openMediaLibrary method or the createMediaLibrary method, you pass in some configuration options. One of the custom options available to the show method is search. So if you pass a search expression, the media library widget will be opened with the search results filtered according to your search expression.
Based on your specification of searching for assets that have the tags 'size-8', 'leather', and 'loafers', this is how that should be passed as part of the configuration options:
search: {
expression:"tags=size-8 AND tags=leather AND tags=loafers",
},You can reference that documentation on the configuration options available to you here: https://cloudinary.com/documentation/media_library_widget#2_set_the_configuration_options
I hope this helps. Please let me know if you have any questions.Kind Regards,
Tia
0 -
Tia-
Thank you for the helpful response! To make sure I understand you correctly, we could add our own UX as a wrapper outside of the widget and call show() with new search expressions when the client changes an option in our UX? That would be a great solution for us, assuming it's performant enough.
- Does show() reload the entire widget, or just update the options in the existing widget?
- Do we need to hide() then show(), or can we just call show() to refresh the widget?
IE if the user changed from 'size-8' to 'size-10' and 'loafers' to 'monkstraps' we would just need to call show() with:
search: {
expression:"tags=size-10 AND tags=leather AND tags=monkstraps",
},https://cloudinary.com/documentation/media_library_widget#show_or_hide_the_media_library
window.ml.show( [options] ) - If you want to adjust any of the Media Library behavior options that were defined when you instantiated the widget, you can optionally pass a new
options
object with the settings you want to change for this particular show session.0 -
Hi Ada,
Sorry for the late response, let me help while Tia is offline.
1. Yes, show() updates the widget with the adjusted options.
2. Yes exactly - when you hide the widget, any adjusted options that were passed in the
show()
command are forgotten, and the settings revert to those set in the initial instantiation. In order to refresh with new adjusted options, please call hide() and then show().
Hope this helps, let me know if you have any further questions,Best regards,
Tamara
0 -
Thank you Tamara - much appreciated. We'll do some performance testing and see if this strategy works well for us.
0
Post is closed for comments.
Comments
4 comments