Plugin Directory

Changeset 514836


Ignore:
Timestamp:
03/05/2012 06:26:12 PM (14 years ago)
Author:
fred91
Message:
 
Location:
simplicy-post-view/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • simplicy-post-view/trunk/readme.txt

    r492207 r514836  
    3636== Changelog ==
    3737
    38 = Version 1.0 (21/05/2011) =<br /> = Version 1.1 (27/06/2011) =<br /> = Version 1.2 (28/10/2011) = = Fixed minor bugs and add css style sheet= <br />= Version 1.3 (18/11/2011) = = Fixed minor bugs = <br />= Version 1.4 (3/12/2011) =  = Fixed bugs Excerpt =
    39 <br />= Version 1.5 (16/12/2011) =  = adding option Select all category  <br /> Version 1.6 (11/01/2012) = = Fixed bugs excerpt <br /> Version 1.7 (19/01/2012) = = change function excerpt
     38= Version 1.0 (21/05/2011) =<br /> = Version 1.1 (27/06/2011) =<br /> = Version 1.2 (28/10/2011) = Fixed minor bugs and add css style sheet= <br />= Version 1.3 (18/11/2011) = = Fixed minor bugs = <br />= Version 1.4 (3/12/2011) =  = Fixed bugs Excerpt =
     39<br />= Version 1.5 (16/12/2011) = adding option Select all category  <br /> Version 1.6 (11/01/2012) = Fixed bugs excerpt <br /> Version 1.7 (19/01/2012) = = change function excerpt <br />
     40Version 1.8 (5/03/2012) = change function URL attachement image post
    4041
  • simplicy-post-view/trunk/simplicy-post-view.php

    r492694 r514836  
    22/*
    33 * Plugin Name: Simplicy post view
    4  * Version: 1.7
     4 * Version: 1.8
    55 * Plugin URI: http://plugins.svn.wordpress.org/simplicy-post-view/
    66 * Description: afficher vos article avec miniature dans votre sidebar.
     
    226226 
    227227
    228 function vp_get_thumbs_url($text)
     228function vp_get_thumbs_url()
    229229{
    230   global $post;
    231  
    232   $imageurl="";       
    233  
    234   // extract the thumbnail from attached imaged
    235   $allimages =&get_children('post_type=attachment&post_mime_type=image&post_parent=' . $post->ID );       
    236  
    237   foreach ($allimages as $img){               
    238      $img_src = wp_get_attachment_image_src($img->ID);
    239      break;                       
    240   }
    241  
    242   $imageurl=$img_src[0];
    243  
    244  
    245   // try to get any image
    246   if (!$imageurl)
    247   {
    248     preg_match('/<\s*img [^\>]*src\s*=\s*[\""\']?([^\""\'>]*)/i' ,  $text, $matches);
    249     $imageurl=$matches[1];
    250   }
    251  
    252   // try to get youtube video thumbnail
    253   if (!$imageurl)
    254   {
    255     preg_match("/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $text, $matches2);
    256  
    257     $youtubeurl = $matches2[0];
    258     if ($youtubeurl)
    259      $imageurl = "http://i.ytimg.com/vi/{$matches2[3]}/1.jpg";
    260    else preg_match("/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/(v\/)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $text, $matches2);
    261  
    262    $youtubeurl = $matches2[0];
    263    if ($youtubeurl)
    264      $imageurl = "http://i.ytimg.com/vi/{$matches2[3]}/1.jpg";
    265   }
    266  
    267  
    268 return $imageurl;
     230 global $post, $posts;
     231
     232$first_img = '';
     233
     234if(has_post_thumbnail() ) {
     235
     236$image_id = get_post_thumbnail_id(); 
     237
     238$image_url = wp_get_attachment_image_src($image_id,'large'); 
     239
     240$image_url = $image_url[0];
     241
     242$first_img = $image_url ;
     243
     244}
     245
     246if(!has_post_thumbnail() ) {
     247
     248if( get_post_meta($post->ID, 'articleimg', true)) {
     249
     250$first_img = get_post_meta($post->ID, 'articleimg', true);
     251
     252}
     253
     254// no field
     255
     256if(empty($first_img)){
     257
     258ob_start();
     259
     260ob_end_clean();
     261
     262$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
     263
     264$first_img = $matches [1] [0];
     265
     266}
     267
     268}
     269
     270return $first_img;
    269271}
    270272
Note: See TracChangeset for help on using the changeset viewer.