• manthano

    (@manthano)


    I’m trying to extend this plugin to add support for adding a playlist (utilizing WP’s [playlist] shortcode). I have two button fields, one for an image and one for the audio files each with different data- attributes set (media-type, select-multiple, etc).

    If I click the built-in image field button first then I can select an image like normal, but when I then go to click the playlist button it doesn’t “reload” the media manager and all I can choose are images.

    If I click my playlist field button then I can select multiple audio files and their ids are returned like I would expect. But then when I click the built-in image field button only audio files are available in the media manager.

    In other words it looks like it’s bringing up the same instance of the Media Manager. How can I get it to reload?

    I can kinda get it work by selecting the image, saving the widget, reloading the page, then selecting the playlist and saving again, but that’s kinda janky.

    Here’s a pastebin of what I have… https://pastebin.com/i22adKR7

    https://www.ads-software.com/plugins/simple-image-widget/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Brady Vercher

    (@bradyvercher)

    The instance of the media manager is cached so it can be reused, which is why you’re seeing that behavior. I have some code in there that would allow for new instances to be created, but it’s not exposed at the moment.

    That particular state wasn’t really designed for selecting and managing multiple attachments, though, so you might be better off trying to use the playlist functionality built into WordPress.

    Here’s some code that should help you get started. Just enqueue this script and change your button class to .tw-spw-control-choose:

    https://pastebin.com/Rb4BEM7x

    Thread Starter manthano

    (@manthano)

    That worked great. Thanks much.

    The only little issue I still have is that if I click the “choose a playlist” button multiple times to update the selection, the instructions in the media manager (“Drag and drop to reorder tracks.”) occurs multiple times, and more each time the frame is opened, both at the top and the bottom of the frame. It goes from occurring once on first open to 3x on second open to 13x to 60x and at that point it overflows the frame.

    Any ideas on how to correct that?

    https://pastebin.com/Ebvfg4Wt

    Also, there’s probably a better way to handle the update function, but I’m new to backbone and what I have is working.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Extending to support [playlist]’ is closed to new replies.