Changeset 1989 for plugins/efiMetadatas/_widgets.php
- Timestamp:
- 12/18/09 01:47:08 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/efiMetadatas/_widgets.php
r1918 r1989 68 68 if ($w->category != 'null' && $w->category != '' && $w->category != $_ctx->posts->cat_id) return; 69 69 70 # Path and url 71 $p_url = $core->blog->settings->public_url; 72 $p_site = preg_replace('#^(.+?//.+?)/(.*)$#','$1',$core->blog->url); 73 $p_root = $core->blog->public_path; 70 # Content lookup 71 $text = $_ctx->posts->post_excerpt_xhtml.$_ctx->posts->post_content_xhtml; 74 72 75 # Image pattern 76 $pattern = '(?:'.preg_quote($p_site,'/').')?'.preg_quote($p_url,'/'); 77 $pattern = sprintf('/<img.+?src="%s(.*?\.(?:jpg|gif|png))"[^>]+/msu',$pattern); 78 79 # Content lookup 80 $subject = $_ctx->posts->post_excerpt_xhtml.$_ctx->posts->post_content_xhtml; 73 # Find source image 74 $img = efiMetadatas::imgSource($core,$text,$w->thumbsize); 81 75 82 76 # No image 83 if (!preg_match_all($pattern,$subject,$m)) return; 84 85 $src = false; 86 $size = $w->thumbsize; 87 $alt = $metas = $thumb = ''; 88 $allowed_ext = array('.jpg','.JPG','.png','.PNG','.gif','.GIF'); 89 90 # Loop through images 91 foreach ($m[1] as $i => $img) 92 { 93 $src = false; 94 $info = path::info($img); 95 $base = $info['base']; 96 $ext = $info['extension']; 97 98 # Not original 99 if (preg_match('/^\.(.+)_(sq|t|s|m)$/',$base,$mbase)) 100 { 101 $base = $mbase[1]; 102 } 103 104 # Full path 105 $f = $p_root.'/'.$info['dirname'].'/'.$base; 106 107 # Find extension 108 foreach($allowed_ext as $end) 109 { 110 if (file_exists($f.$end)) 111 { 112 $src = $f.$end; 113 break; 114 } 115 } 116 117 # No file 118 if (!$src) continue; 119 120 # Find thumbnail 121 if (!empty($size)) 122 { 123 $t = $p_root.'/'.$info['dirname'].'/.'.$base.'_'.$size.'.jpg'; 124 if (file_exists($t)) 125 { 126 $thb = $p_url.(dirname($img) != '/' ? dirname($img) : '').'/.'.$base.'_'.$size.'.jpg'; 127 } 128 } 129 130 # Find image description 131 if (preg_match('/alt="([^"]+)"/',$m[0][$i],$malt)) 132 { 133 $alt = $malt[1]; 134 } 135 break; 136 } 137 138 # No image 139 if (!$src || !file_exists($src)) return; 140 141 # Image info 142 $metas_array = imageMeta::readMeta($src); 77 if (!$img['source']) return; 143 78 144 79 # List metas 145 foreach($metas_array as $k => $v) 80 $metas = efiMetadatas::imgMeta($core,$img['source']); 81 82 $content = ''; 83 foreach($metas as $k => $v) 146 84 { 147 if (!$w->showmeta && !$v) continue; 148 $metas .= '<li><strong>'.__($k.':').'</strong><br />'.$v.'</li>'; 85 // keep empty meta if wanted 86 if (!$w->showmeta && empty($v[1])) continue; 87 $content .= '<li class="efi-'.$k.'"><strong>'.$v[0].':</strong><br />'.$v[1].'</li>'; 149 88 } 150 89 151 90 # No meta 152 if (empty($metas)) return; 153 91 if (empty($content)) return; 154 92 155 93 # thumbnail 156 if ( !empty($thb))94 if ($img['thumb']) 157 95 { 158 96 $thumb = 159 97 '<div class="img-box">'. 160 98 '<div class="img-thumbnail">'. 161 '<img alt="'.$ alt.'" src="'.$thb.'" />'.99 '<img alt="'.$img['title'].'" src="'.$img['thumb'].'" />'. 162 100 '</div>'. 163 101 "</div>\n"; … … 168 106 ($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : ''). 169 107 $thumb. 170 '<ul>'.$ metas.'</ul>'.108 '<ul>'.$content.'</ul>'. 171 109 '</div>'; 172 110 }
Note: See TracChangeset
for help on using the changeset viewer.