'amty_thumb', 'description' => __('It displays recently published posts with thumbnail', 'amty_thumb_recent') ); /* Widget control settings. */ $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'amty-thumb-recent' ); /* Create the widget. */ $this->WP_Widget( 'amty-thumb-recent', __('Amty Thumb Recent', 'amty_thumb_recent'), $widget_ops, $control_ops ); } function update( $new_instance, $old_instance ) { $instance = $old_instance; /* Strip tags for title and width & Height to remove HTML (important for text inputs). */ $instance['title'] = strip_tags( $new_instance['title'] ); $instance['maxpost'] = strip_tags( $new_instance['maxpost'] ); $instance['width'] = strip_tags( $new_instance['width'] ); $instance['height'] = strip_tags( $new_instance['height'] ); $instance['border'] = strip_tags( $new_instance['border'] ); $instance['itemwidth'] = strip_tags( $new_instance['itemwidth'] ); $instance['itemheight'] = strip_tags( $new_instance['itemheight'] ); $instance['itemborder'] = strip_tags( $new_instance['itemborder'] ); $instance['titlelen'] = strip_tags( $new_instance['titlelen'] ); /* No need to strip tags for icon */ $instance['icon'] = $new_instance['icon']; $instance['icontype'] = $new_instance['icontype']; //$instance['show_default'] = $new_instance['show_default']; $instance['imagepath'] = $new_instance['imagepath']; $instance['pretag'] = $new_instance['pretag']; $instance['posttag'] = $new_instance['posttag']; $instance['displaytype'] = $new_instance['displaytype']; $instance['templateItems'] = $new_instance['templateItems']; return $instance; } function form( $instance ) { /* Set up some default widget settings. */ $defaults = array( 'title' => __('Amty Thumb Recent', 'amty_thumb_recent'), 'width' => __('70', 'amty_thumb_recent'), 'height' => __('70', 'amty_thumb_recent'), 'border' => __('1', 'amty_thumb_recent'), 'icon' => 'yes', 'show_icon' => true, 'icontype' => 'any', 'imagepath' => __('', 'amty_thumb_recent'), 'pretag' => __('', 'amty_thumb_recent'), 'posttag' => __('', 'amty_thumb_recent'), 'titlelen' => __(50, 'amty_thumb_recent'), 'displaytype' => __('Vertically', 'amty_thumb_recent'), 'templateItems' => __('image', 'amty_thumb_recent'), 'itemwidth' => __('50', 'amty_thumb_recent'), 'itemheight' => __('50', 'amty_thumb_recent'), 'itemborder' => __('0', 'amty_thumb_recent'), 'maxpost' => __('5', 'amty_thumb_recent') ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>


Thumbnail

First Image.

id="get_field_id( 'show_default'); ?>" name="get_field_name( 'show_default'); ?>" />

*/?>


Title


Template

View: Show first.

In case of Vertical view



* get_results("SELECT guid, post_content, post_mime_type, post_title FROM $wpdb->posts WHERE post_parent = $id ORDER BY ID ASC"); $match_count = preg_match_all("//", $image_data[0]->post_content, $match_array, PREG_PATTERN_ORDER); $img = $match_array[1][0]; $first_image_data = array ($image_data[0]); //array output foreach($first_image_data as $output) { $style = "style=\"width:".$w."px; height:".$h."px; border:".$b."px solid; margin:1px;\" "; //if there is no description use title (filename) instead if (empty($output->post_content) == TRUE) {$output->post_content = $output->post_title;} //images if (substr($output->post_mime_type, 0, 5) == 'image' && $imagetype = 'uploaded') {echo "guid\" alt=\"$output->post_title\" title=\"$output->post_content\" $style />";} else //exist on external server or attached image { $attach_img = amty_get_firstimage1($output->guid); if($attach_img != '' && $imagetype = 'attached') //Image attached as a metadata echo " "; elseif($img !='' && $imagetype = 'referenced') //image on remote machine echo " "; else{ if (substr($output->post_mime_type, 0, 5) == 'image') {echo "guid\" alt=\"$output->post_title\" title=\"$output->post_content\" $style />";} else //exist on external server or attached image { $attach_img = amty_get_firstimage1($output->guid); if($attach_img = '') //Image attached as a metadata echo " "; elseif($img !='') //image on remote machine echo " "; else //Post has no image echo ""; }//inner else end }//outer else end } }//foreach end }//function end function amty_get_firstimage1($post_id='', $size='thumbnail') { $id = (int) $post_id; $args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => 1, 'order' => 'ASC', 'orderby' => 'menu_order ID', 'post_status' => null, 'post_parent' => $id ); $attachments = get_posts($args); if ($attachments) { $img = wp_get_attachment_image_src($attachments[0]->ID, $size); return $img[0]; }else{ return ''; } } ?>