Changeset 1037485
- Timestamp:
- 12/03/2014 01:59:52 PM (11 years ago)
- File:
-
- 1 edited
-
super-link-preview/trunk/super-link-preview.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
super-link-preview/trunk/super-link-preview.php
r1037377 r1037485 5 5 Description: Generate a preview (aka thumbnail) of any external link in the page, similar to Facebook or Google+ snippets. 6 6 Author: Daniele Perilli 7 Version: 1.0. 07 Version: 1.0.1 8 8 Author URI: https://www.behance.net/danieleperilli 9 9 */ … … 158 158 /* 159 159 * Shortcode 160 * usage: [link-preview url="link-to-website" width="x" alt="description"forceshot="false"]160 * usage: [link-preview url="link-to-website" width="x" forceshot="false"] 161 161 */ 162 162 public function plugin_shortcode( $attributes, $content = '', $code = '' ) { … … 168 168 'url' => '', 169 169 'width' => 0, 170 'alt' => '',171 170 'forceshot' => false 172 171 ), $attributes )); … … 230 229 $html .= ' width="' . $width . '"'; 231 230 232 $html .= ' alt="' . $alt . '" /></a></div>'; 231 $title = get_post_meta($post->ID, $this->cf_prefix . "title-" . $slug, true); 232 if (isset($title) && !empty($title)) 233 $html .= ' alt="' . $title . '" title="' + $title + '"'; 234 235 $html .= ' /></a></div>'; 233 236 234 237 return $html; … … 308 311 309 312 $image_url = ""; 310 311 //Get OpenGraph image 313 $url_title = ""; 314 315 //Get OpenGraph image and title 312 316 $parse_og_meta = get_option($this->plugin_name . '_img_og_meta', true); 313 317 if ($parse_og_meta) { 314 318 foreach($document->getElementsByTagName('meta') as $meta_tag) { 315 316 if ($meta_tag->getAttribute('property') == 'og:image'){ 317 $image_url = $meta_tag->getAttribute('content'); 319 320 if (empty($image_url)) { 321 if ($meta_tag->getAttribute('property') == 'og:image'){ 322 $image_url = $meta_tag->getAttribute('content'); 323 } 324 } 325 326 if (empty($url_title)) { 327 if ($meta_tag->getAttribute('property') == 'og:title'){ 328 $url_title = $meta_tag->getAttribute('content'); 329 } 330 } 331 332 if (!empty($image_url) && !empty($url_title)) 318 333 break; 319 }320 321 334 } 322 } 335 336 } 337 338 //Get document title 339 if (empty($url_title)) { 340 $title_tag = $document->getElementsByTagName("title"); 341 if($title_tag->length > 0) 342 $url_title = $title_tag->item(0)->nodeValue; 343 } 344 345 if (!empty($url_title)) { 346 347 //TODO Strip URLS from title 348 349 //TODO Save title as post title if untitled 350 351 //Save title in a custom field 352 update_post_meta($post_id, $this->cf_prefix . "title-" . $slug, $url_title); 353 354 } 355 356 323 357 if (!$this->has_right_size($image_url)) { 324 358 … … 366 400 367 401 if ($image_url && !empty($image_url) && is_string($image_url)) { 402 403 //Check if url is valid 404 if (filter_var($image_url, FILTER_VALIDATE_URL) === false) 405 return false; 368 406 369 407 if ($images_min_width > 0 || $images_min_height > 0 || !$this->images_allow_ads || !$this->images_allow_square) {
Note: See TracChangeset
for help on using the changeset viewer.