• Resolved stephenrusselcrane@yahoo.com

    (@stephenrusselcraneyahoocom)


    I’m trying to figure out how to upload multiple images with this pluggin. what am i missing? See the sight

    if( class_exists( 'WidgetImageField' ) )
    add_action( 'widgets_init', create_function( '', "register_widget( 'image_rotator' );" ) );
    
    class ITI_Widget_Image_OTM extends WP_Widget
    {
    var $image_field = 'image'; // the image field ID
    
    function __construct()
    {
    $widget_ops = array(
    'classname' => 'image_rotator',
    'description' => __( "Image Rotator")
    );
    parent::__construct( 'image_rotator', __('Image Rotator'), $widget_ops );
    }
    
    function form( $instance )
    {
    $image_id = esc_attr( isset( $instance[$this->image_field] ) ? $instance[$this->image_field] : 0 );
    
    $image_id2 = esc_attr( isset( $instance[$this->image_field] ) ? $instance[$this->image_field] : 0 );
    
    $image = new WidgetImageField( $this, $image_id );
    $image2 = new WidgetImageField( $this, $image_id2 );
    ?>
    <h3>Image One:</h3>
    <div>
    <label><?php _e( 'Image:' ); ?></label>
    <?php echo $image->get_widget_field(); ?>
    </div>
    <h3>Image Two:</h3>
    <div>
    <label><?php _e( 'Image:' ); ?></label>
    <?php echo $image2->get_widget_field(); ?>
    </div>
    <?php
    }
    
    function widget( $args, $instance )
    {
    extract($args);
    
    $image_id = $instance[$this->image_field];
    
    $image_id2 = $instance[$this->image_field];
    
    $image = new WidgetImageField( $this, $image_id );
    $image2 = new WidgetImageField( $this, $image_id2 );
    
    echo $before_widget;
    
    ?>
    <?php if( !empty( $image ) ) : ?>
    <img src="<?php echo $image->get_image_src( 'thumbnail' ); ?>" width="<?php echo $image->get_image_width( 'thumbnail' ); ?>" height="<?php echo $image->get_image_height( 'thumbnail' ); ?>" />
    <?php endif; ?>
    <?php if( !empty( $image2 ) ) : ?>
    <img src="<?php echo $image2->get_image_src( 'thumbnail' ); ?>" width="<?php echo $image2->get_image_width( 'thumbnail' ); ?>" height="<?php echo $image2->get_image_height( 'thumbnail' ); ?>" />
    <?php endif; ?>
    <?php
    
    echo $after_widget;
    }
    
    function update( $new_instance, $old_instance )
    {
    $instance = $old_instance;
    
    $instance[$this->image_field] = intval( strip_tags( $new_instance[$this->image_field] ) );
    $instance[$this->image_field] = intval( strip_tags( $new_instance[$this->image_field] ) );
    
    return $instance;
    }
    }
    
    add_action('widgets_init', create_function('', 'return register_widget("ITI_Widget_Image_OTM");'));
    
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple Images’ is closed to new replies.