This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Using an image as `item_label`. Is this possible?

8 years ago · Last reply by Alex S 8 years ago

Hi! First of all: Thank you very much this powerful tool. SOPB is simply amazing.

I am currently building a custom set of widgets in order to make my Storytelling Kit. One of them will be a simple Slideshow. I am using a repeater width `media` elements inside. Is it possible to set the `item_label` of the repeater to display a thumbnail of that image?

I am a not-so-skilled developer, so any help would bne welcome.

function __construct() {
    //Here you can do any preparation required before calling the parent constructor, such as including additional files or initializing variables.
    //Call the parent constructor with the required arguments.
    parent::__construct(
        // The unique id for your widget.
        'sopb-image-carousel',
        // The name of the widget for display purposes.
        __('Image Carousel', 'sopb-widgets'),
        // The $widget_options array, which is passed through to WP_Widget.
        // It has a couple of extras like the optional help URL, which should link to your sites help or support page.
        array(
            'description'   => __('Place an image-carousel slideshow in your story.', 'sopb-widgets'),
            'panels_groups' => array('bmwf'),
            'panels_icon'   => 'dashicons dashicons-images-alt2',
            // 'help'        => 'http://example.com/hello-world-widget-docs',
        ),
        //The $control_options array, which is passed through to WP_Widget
        array(
        ),
        //The $form_options array, which describes the form fields used to configure SiteOrigin widgets. We'll explain these in more detail later.
         array(
          'carousel_repeater' => array(
            'type'      => 'repeater',
            'label'     => __( 'Click 'add' to add an image to the slideshow.' , 'sopb-widgets' ),
            'item_name' => __( 'Carousel Slide', 'sopb-widgets' ),
            'item_label' => array(
                'selector'     => "[id*='media']",
                'update_event' => 'change',
                'value_method' => 'val'
            ),
            'fields' => array(
              'image' => array(
                'type'     => 'media',
                'label'    => __('Select or upload an image.', 'sopb-widgets'),
                'choose'   => __('Choose image', 'sopb-widgets'),
                'library'  => 'image',
                'fallback' => false
              ),
              'imgcaption' => array(
                'type'     => 'textarea',
                'label'    => __('Enter a caption for the image. (optional)', 'sopb-widgets'),
                'optional' => true,
                'default'  => '',
                'rows'     => 3
              ),
              'photocredit' => array(
                'type'     => 'text',
                'label'    => __('Photocredit (optional)', 'sopb-widgets'),
                'optional' => true,
                'default'  => '',
                'rows'     => 2
              ),
            ),
          ),
        ),
(...and so on)

THX!

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

1
  1. Alex S Staff 8 years, 7 months ago

    Hi Sebaldundsoehne,

    Unfortunately, this isn’t currently possible as the menu item is filtered on load. Can you please clarify the type of image you would like to show? I ask as I’ll include this use case in the feature request I’ll log.

Replies on this thread are closed.

Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Have a different question or issue?

Start New Thread