Home>Support>Using an image as `item_label`. Is this possible?

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

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. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 7 years, 3 months ago Alex S
    Hi, I Work Here

    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.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More