Open Graph for Facebook, Google+ and Twitter Card Tags - Version 1.3.1

Version Description

  • Ignore images bellow 200x200 when searching images from the post content and media gallery, because Facebook also ignores them
Download this release

Release Info

Developer webdados
Plugin Icon Open Graph for Facebook, Google+ and Twitter Card Tags
Version 1.3.1
Comparing to
See all releases

Code changes from version 1.3 to 1.3.1

Files changed (2) hide show
  1. readme.txt +4 -1
  2. wonderm00n-open-graph.php +33 -19
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://blog.wonderm00n.com/2011/10/14/wordpress-plugin-simple-faceb
4
  Tags: facebook, open graph, open graph protocol, seo, share, social, meta, twitter card, twitter, schema, google+, g+, google, google plus, image, like, meta, search engine optimization
5
  Requires at least: 3.5
6
  Tested up to: 4.0.1
7
- Stable tag: 1.3
8
 
9
  Inserts Facebook Open Graph, Google+/Schema.org, Twitter and other Meta Tags into your WordPress Website for more efficient sharing results.
10
 
@@ -74,6 +74,9 @@ It allows the user to choose which tags are, or not, included and also the defau
74
 
75
  == Changelog ==
76
 
 
 
 
77
  = 1.3 =
78
  * Changed name to "Facebook Open Graph, Google+ and Twitter Card Tags"
79
  * Added Twitter Card tags
4
  Tags: facebook, open graph, open graph protocol, seo, share, social, meta, twitter card, twitter, schema, google+, g+, google, google plus, image, like, meta, search engine optimization
5
  Requires at least: 3.5
6
  Tested up to: 4.0.1
7
+ Stable tag: 1.3.1
8
 
9
  Inserts Facebook Open Graph, Google+/Schema.org, Twitter and other Meta Tags into your WordPress Website for more efficient sharing results.
10
 
74
 
75
  == Changelog ==
76
 
77
+ = 1.3.1 =
78
+ * Ignore images bellow 200x200 when searching images from the post content and media gallery, because Facebook also ignores them
79
+
80
  = 1.3 =
81
  * Changed name to "Facebook Open Graph, Google+ and Twitter Card Tags"
82
  * Added Twitter Card tags
wonderm00n-open-graph.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
  /**
3
  * @package Facebook Open Graph, Google+ and Twitter Card Tags
4
- * @version 1.3
5
  */
6
  /*
7
  Plugin Name: Facebook Open Graph, Google+ and Twitter Card Tags
8
  Plugin URI: http://www.webdados.pt/produtos-e-servicos/internet/desenvolvimento-wordpress/facebook-open-graph-meta-tags-wordpress/
9
  Description: Inserts Facebook Open Graph, Google+ / Schema.org and Twitter Card Tags into your WordPress Blog/Website for more effective and efficient Facebook, Google+ and Twitter sharing results. You can also choose to insert the "enclosure" and "media:content" tags to the RSS feeds, so that apps like RSS Graffiti and twitterfeed post the image to Facebook correctly.
10
- Version: 1.3
11
  Author: Webdados
12
  Author URI: http://www.webdados.pt
13
  Text Domain: wd-fb-og
@@ -16,7 +16,7 @@ Domain Path: /lang
16
 
17
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
18
 
19
- $wonderm00n_open_graph_plugin_version='1.3';
20
  $wonderm00n_open_graph_plugin_name='Facebook Open Graph, Google+ and Twitter Card Tags';
21
  $wonderm00n_open_graph_plugin_settings=array(
22
  'fb_app_id_show',
@@ -450,32 +450,46 @@ function wonderm00n_open_graph_post_image($fb_image_use_specific=1,$fb_image_use
450
  if (intval($fb_image_use_content)==1) {
451
  $imgreg = '/<img .*src=["\']([^ ^"^\']*)["\']/';
452
  preg_match_all($imgreg, trim($post->post_content), $matches);
453
- if (isset($matches[1][0])) {
454
- //There's an image on the content
455
- $image=$matches[1][0];
456
- $pos = strpos($image, site_url());
457
- if ($pos === false) {
458
- if (stristr($image, 'http://') || stristr($image, 'https://')) {
459
- //Complete URL - offsite
460
- $fb_image=$image;
 
 
 
461
  } else {
462
- $fb_image=site_url().$image;
 
463
  }
464
- } else {
465
- //Complete URL - onsite
466
- $fb_image=$image;
 
 
 
 
467
  }
468
- $thumbdone=true;
469
  }
470
  }
471
  }
472
  //From media gallery
473
  if (!$thumbdone) {
474
  if (intval($fb_image_use_media)==1) {
475
- $images = get_posts(array('post_type' => 'attachment','numberposts' => 1,'post_status' => null,'order' => 'ASC','orderby' => 'menu_order','post_mime_type' => 'image','post_parent' => $post->ID));
476
  if ($images) {
477
- $fb_image=wp_get_attachment_url($images[0]->ID, false);
478
- $thumbdone=true;
 
 
 
 
 
 
 
479
  }
480
  }
481
  }
1
  <?php
2
  /**
3
  * @package Facebook Open Graph, Google+ and Twitter Card Tags
4
+ * @version 1.3.1
5
  */
6
  /*
7
  Plugin Name: Facebook Open Graph, Google+ and Twitter Card Tags
8
  Plugin URI: http://www.webdados.pt/produtos-e-servicos/internet/desenvolvimento-wordpress/facebook-open-graph-meta-tags-wordpress/
9
  Description: Inserts Facebook Open Graph, Google+ / Schema.org and Twitter Card Tags into your WordPress Blog/Website for more effective and efficient Facebook, Google+ and Twitter sharing results. You can also choose to insert the "enclosure" and "media:content" tags to the RSS feeds, so that apps like RSS Graffiti and twitterfeed post the image to Facebook correctly.
10
+ Version: 1.3.1
11
  Author: Webdados
12
  Author URI: http://www.webdados.pt
13
  Text Domain: wd-fb-og
16
 
17
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
18
 
19
+ $wonderm00n_open_graph_plugin_version='1.3.1';
20
  $wonderm00n_open_graph_plugin_name='Facebook Open Graph, Google+ and Twitter Card Tags';
21
  $wonderm00n_open_graph_plugin_settings=array(
22
  'fb_app_id_show',
450
  if (intval($fb_image_use_content)==1) {
451
  $imgreg = '/<img .*src=["\']([^ ^"^\']*)["\']/';
452
  preg_match_all($imgreg, trim($post->post_content), $matches);
453
+ if ($matches[1]) {
454
+ foreach($matches[1] as $image) {
455
+ //There's an image on the content
456
+ $pos = strpos($image, site_url());
457
+ if ($pos === false) {
458
+ if (stristr($image, 'http://') || stristr($image, 'https://')) {
459
+ //Complete URL - offsite
460
+ $imagetemp=$image;
461
+ } else {
462
+ $imagetemp=site_url().$image;
463
+ }
464
  } else {
465
+ //Complete URL - onsite
466
+ $imagetemp=$image;
467
  }
468
+ $img_size = getimagesize($imagetemp);
469
+ if ($img_size[0] >= 200 && $img_size[1] >= 200) {
470
+ $fb_image=$imagetemp;
471
+ $thumbdone=true;
472
+ break;
473
+ }
474
+
475
  }
 
476
  }
477
  }
478
  }
479
  //From media gallery
480
  if (!$thumbdone) {
481
  if (intval($fb_image_use_media)==1) {
482
+ $images = get_posts(array('post_type' => 'attachment','numberposts' => -1,'post_status' => null,'order' => 'ASC','orderby' => 'menu_order','post_mime_type' => 'image','post_parent' => $post->ID));
483
  if ($images) {
484
+ foreach($images as $image) {
485
+ $imagetemp=wp_get_attachment_url($image->ID, false);
486
+ $img_size = getimagesize($imagetemp);
487
+ if ($img_size[0] >= 200 && $img_size[1] >= 200) {
488
+ $fb_image=$imagetemp;
489
+ $thumbdone=true;
490
+ break;
491
+ }
492
+ }
493
  }
494
  }
495
  }