faysalmirmd

k2 component thumbs fetch - joomla

Nov 26th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $thumbtempsrc                       = JPATH_ROOT.DIRECTORY_SEPARATOR.'media'.DIRECTORY_SEPARATOR.'k2'.DIRECTORY_SEPARATOR.'items'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.md5("Image".$item->id).'_L.jpg';                                                      
  2.                         $img_temp     = false;
  3.                         if(file_exists($thumbtempsrc)){  
  4.                            $img_temp     = true;
  5.                            $imgpath      = JURI::base().'/media/k2/items/cache/'.md5('Image'.$item->id).'_L.jpg';                        
  6.                         }
  7.  
  8.                         if(!$img_temp){
  9.                             $img_temp    = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $item->introtext,$matches)?true
  10.                                           :preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $item->fulltext,$matches);
  11.                             $imgpath     = ($img_temp ? $matches[1][0]:'');
  12.                         }
  13.  
  14.                         $singlarticletemp->image = $imgpath ? $imgpath:'';
  15.  
  16.                         if($singlarticletemp->image && strpos($singlarticletemp->image,'http') === false){
  17.                             $singlarticletemp->image = JURI::base().$singlarticletemp->image;
  18.                         }
Advertisement
Add Comment
Please, Sign In to add comment