Option for tag1 AND tag2 AND tag3 in Media Library Widget?

Comments

4 comments

  • Avatar
    Tia Esguerra

    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
    Comment actions Permalink
  • Avatar
    Ada Diamonds

    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.

    1. Does show() reload the entire widget, or just update the options in the existing widget?
    2. 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
    Comment actions Permalink
  • Avatar
    Tamara Yulevich

    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
    Comment actions Permalink
  • Avatar
    Ada Diamonds

    Thank you Tamara - much appreciated. We'll do some performance testing and see if this strategy works well for us.

    0
    Comment actions Permalink

Please sign in to leave a comment.