'Image', 'description' => 'Image description', 'icon_class' => 'fa fa-image', 'container' => false, 'has_content' => false, 'defaults' => array(), ); parent::__construct($id_base, $name, $options); } function init(){ $this->enqueue_js('el-image',dirname(__FILE__).'/../../view/js/elements/ve-image.js'); $this->ready('if (typeof ve_front !== "undefined"){ve_front.image.start();}'); $this->support('CssEditor'); } function element($instance,$content=''){ $instance=shortcode_atts( array( 'title' => '', 'css_animation' => '', 'alignment'=>'', 'style' => '', 'img_link_large'=>'', 'img_link_target'=>'_self', 'link'=>'', 'img_size' => 'thumbnail', 'image' => '', 'class' => '', 'width' => '', 'height' => '', 'interval' => '5', ), $instance ); $style = $instance['style']; $image=$instance['image']; $img_size=$instance['img_size']; if($img_size == "custom") { $img_size = $instance['width'] .'x' . $instance['height']; } $img_link_large=$instance['img_link_large']; $css_animation=$instance['css_animation']; $alignment=$instance['alignment']; $title=$instance['title']; $link=$instance['link']; $img_id = preg_replace( '/[^\d]/', '', $image ); $img = ve_get_attachment_image( array( 'attach_id' => $img_id, 'thumb_size' => $img_size, 'class' => $style ) ); if ( $img == NULL ) $img['thumbnail'] = ''; $el_class = $instance['class']; $a_class = ''; if ( $el_class != '' ) { $tmp_class = explode( " ", strtolower( $el_class ) ); $tmp_class = str_replace( ".", "", $tmp_class ); if ( in_array( "prettyphoto", $tmp_class ) ) { wp_enqueue_script( 'prettyphoto' ); wp_enqueue_style( 'prettyphoto' ); $a_class = ' class="prettyphoto"'; $el_class = str_ireplace( "prettyphoto", "", $el_class ); } } $link_to = ''; if ( $img_link_large == true ) { $link_to = wp_get_attachment_image_src( $img_id, 'large' ); $link_to = $link_to[0]; } else if ( strlen($link) > 0 ) { $link_to = $link; } else if ( ! empty( $img_link ) ) { $link_to = $img_link; if ( ! preg_match( '/^(https?\:\/\/|\/\/)/', $link_to ) ) $link_to = 'http://' . $link_to; } $img_link_target=$instance['img_link_target']; $img_output = ( $style == 've_box_shadow_3d' ) ? '' . $img['thumbnail'] . '' : $img['thumbnail']; $image_string = ! empty( $link_to ) ? '' . $img_output . '' : $img_output; $css_class = $el_class; $css_class .= $this->getCSSAnimation( $css_animation ); if($alignment) $css_class .= ' ve_align_' . $alignment; $this->addClass($css_class); $this->element_title($title); $this->element_content($image_string); } public function getCSSAnimation( $css_animation ) { $output = ''; if ( $css_animation != '' ) { wp_enqueue_script( 'waypoints' ); $output = ' ve_animate_when_almost_visible ve_ani_' . $css_animation; } return $output; } function form($instance){ $instance=shortcode_atts( array( 'title' => '', 'css_animation' => '', 'alignment'=>'', 'style' => '', 'img_link_large'=>'', 'link'=>'', 'img_size' => 'thumbnail', 'image' => '', 'width' => '', 'height' => '', 'class' => '', 'interval' => '5', ), $instance ); $title=$instance['title']; $img_id=$instance['image']; $css_animation=$instance['css_animation']; $img_size=$instance['img_size']; $width=$instance['width']; $height=$instance['height']; $alignment=$instance['alignment']; $style=$instance['style']; $img_link_large=$instance['img_link_large']; $link=esc_attr($instance['link']); $class=$instance['class']; $css_animations=array( ''=>'No', 'top-to-bottom'=>'Top to bottom', 'bottom-to-top'=>'Bottom to top', 'left-to-right'=>'Left to right', 'right-to-left'=>'Right to left', 'appear'=>'Appear from center', ); $img_alignments=array( ''=>'Align left', 'right'=>'Align right', 'center'=>'Align center', ); $img_styles=array( ''=>'Default', 've_box_rounded'=>'Rounded', 've_box_border'=>'Border', 've_box_outline'=>'Outline', 've_box_shadow'=>'Shadow', 've_box_shadow_border'=>'Bordered shadow', 've_box_shadow_3d'=>'3D Shadow', 've_box_circle'=>'Circle', 've_box_border_circle'=>'Circle Border', 've_box_outline_circle'=>'Circle Outline', 've_box_shadow_circle'=>'Circle Shadow', 've_box_shadow_border_circle'=>'Circle Border Shadow', ); ?>

Add image


Custom Size:




name="field_name('img_link_large');?>" id="field_id('img_link_large');?>" value="yes"/>

download_image($instance['image_src'],$ve_importing_post)){ $instance['image']=$image; unset($instance['image_src']); } } return parent::import($instance,$content); } function download_image( $file, $post_id, $desc = null ) { if ( ! empty( $file ) ) { // Set variables for storage, fix file filename for query strings. preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches ); $file_array = array(); $file_array['name'] = basename( $matches[0] ); // Download file to temp location. $file_array['tmp_name'] = download_url( $file ); // If error storing temporarily, return the error. if ( is_wp_error( $file_array['tmp_name'] ) ) { return $file_array['tmp_name']; } // Do the validation and storage stuff. $id = media_handle_sideload( $file_array, $post_id, $desc ); // If error storing permanently, unlink. if ( is_wp_error( $id ) ) { @unlink( $file_array['tmp_name'] ); return false; } if(wp_get_attachment_url($id)) return $id; } return false; } }