Title: [202577] trunk/Websites/webkit.org
- Revision
- 202577
- Author
- [email protected]
- Date
- 2016-06-28 11:12:23 -0700 (Tue, 28 Jun 2016)
Log Message
Fixed Open Graph meta data and image entries.
https://bugs.webkit.org/show_bug.cgi?id=159167.
Reviewed by Timothy Hatcher.
This patch addresses Open Graph meta data issues:
- Added a high-resolution PNG of the WebKit logo because Facebook doesn't support SVG images
- Uses the first image of a page or post if not featured image is set
- Article date/time information should not be given for the homepage
- Added Facebook admins as per the Facebook Open Graph debugger
* wp-content/plugins/social-meta.php:
* wp-content/themes/webkit/images/ogimage.png: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/Websites/webkit.org/ChangeLog (202576 => 202577)
--- trunk/Websites/webkit.org/ChangeLog 2016-06-28 18:08:59 UTC (rev 202576)
+++ trunk/Websites/webkit.org/ChangeLog 2016-06-28 18:12:23 UTC (rev 202577)
@@ -1,3 +1,20 @@
+2016-06-28 Jon Davis <[email protected]>
+
+ Fixed Open Graph meta data and image entries.
+ https://bugs.webkit.org/show_bug.cgi?id=159167.
+
+ Reviewed by Timothy Hatcher.
+
+ This patch addresses Open Graph meta data issues:
+
+ - Added a high-resolution PNG of the WebKit logo because Facebook doesn't support SVG images
+ - Uses the first image of a page or post if not featured image is set
+ - Article date/time information should not be given for the homepage
+ - Added Facebook admins as per the Facebook Open Graph debugger
+
+ * wp-content/plugins/social-meta.php:
+ * wp-content/themes/webkit/images/ogimage.png: Added.
+
2016-06-27 Dean Jackson <[email protected]>
Updated content for the color blog post.
Modified: trunk/Websites/webkit.org/wp-content/plugins/social-meta.php (202576 => 202577)
--- trunk/Websites/webkit.org/wp-content/plugins/social-meta.php 2016-06-28 18:08:59 UTC (rev 202576)
+++ trunk/Websites/webkit.org/wp-content/plugins/social-meta.php 2016-06-28 18:12:23 UTC (rev 202577)
@@ -8,34 +8,50 @@
*/
add_action('wp_head', function() {
-
+
$title = get_the_title();
$description = get_the_excerpt();
$type = 'article';
-
+
$categories = array();
$tags = array();
- $image_url = get_stylesheet_directory_uri() . '/images/webkit.svg';
+ $image_url = get_stylesheet_directory_uri() . '/images/ogimage.png';
$twitter_handle = '';
-
+ $published_time = '';
+ $modified_time = '';
+
+ $fb_admins = array(
+ 'Jon Davis' => '1085088865',
+ 'Tim Hatcher' => '854565306'
+ );
+
if (is_front_page() || is_home()) {
$title = get_bloginfo('name');
$description = get_bloginfo('description');
- $type = 'website';
+ $type = 'website';
}
-
+
if (is_single()) {
- $image_src = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'large' );
- $image_url = $image_src[0];
-
+
+ $post = get_post();
+
+ if ( has_post_thumbnail() ) {
+ $image_src = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'large' );
+ $image_url = $image_src[0];
+ } else {
+ preg_match_all('/<img.+src="" $post->post_content, $matches);
+ if ($matches[1][0]) $image_url = $matches[1][0];
+ }
+
$categories = wp_get_object_terms(get_the_ID(), 'category', array('fields' => 'names'));
$tags = wp_get_object_terms(get_the_ID(), 'post_tag', array('fields' => 'names'));
// Post author data is not available in wp_head filter context
- $post = get_post();
$twitter_handle = get_the_author_meta('twitter', $post->post_author);
+ $published_time = get_the_time('c');
+ $modified_time = get_the_modified_date('c');
}
-
+
?>
<!-- Schema.org markup -->
@@ -62,24 +78,28 @@
<?php endif; ?>
<!-- Open Graph data -->
- <meta property="og:title" content="<?php echo esc_attr($title); ?>" />
- <meta property="og:type" content="<?php echo esc_attr($type); ?>" />
- <meta property="og:url" content="<?php the_permalink(); ?>" />
+ <meta property="og:title" content="<?php echo esc_attr($title); ?>">
+ <meta property="og:type" content="<?php echo esc_attr($type); ?>">
+ <meta property="og:url" content="<?php the_permalink(); ?>">
<?php if ($image_url): ?>
<meta itemprop="og:image" content="<?php echo esc_url($image_url); ?>">
<?php endif; ?>
<?php if ($description): ?>
- <meta property="og:description" content="<?php echo esc_attr($description); ?>" />
+ <meta property="og:description" content="<?php echo esc_attr($description); ?>">
<?php endif; ?>
- <meta property="og:site_name" content="<?php bloginfo('title'); ?>" />
- <meta property="article:published_time" content="<?php the_time('c'); ?>" />
- <meta property="article:modified_time" content="<?php the_modified_date('c'); ?>" />
+ <meta property="og:site_name" content="<?php bloginfo('title'); ?>">
+<?php if ($published_time): ?>
+ <meta property="article:published_time" content="<?php echo $published_time; ?>">
+<?php endif; ?>
+<?php if ($modified_time): ?>
+ <meta property="article:modified_time" content="<?php echo $modified_time; ?>">
+<?php endif; ?>
<?php
if (!empty($categories)):
$section = array_shift($categories); // The first category is used as the section
$tags = array_merge($categories, $tags); // The rest are prepended to the tag list
?>
- <meta property="article:section" content="<?php echo esc_attr($section); ?>" />
+ <meta property="article:section" content="<?php echo esc_attr($section); ?>">
<?php
endif;
@@ -86,11 +106,16 @@
if (!empty($tags)):
foreach($tags as $tag):
?>
- <meta property="article:tag" content="<?php echo esc_attr($tag); ?>" />
-<?php
- endforeach;
+ <meta property="article:tag" content="<?php echo esc_attr($tag); ?>">
+<?php
+ endforeach;
endif;
+
+ if (!empty($fb_admins)):
+ foreach($fb_admins as $id):
?>
-
+ <meta property="fb:admins" content="<?php echo esc_attr($id); ?>">
<?php
+ endforeach;
+ endif;
});
\ No newline at end of file
Added: trunk/Websites/webkit.org/wp-content/themes/webkit/images/ogimage.png
(Binary files differ)
Index: trunk/Websites/webkit.org/wp-content/themes/webkit/images/ogimage.png
===================================================================
--- trunk/Websites/webkit.org/wp-content/themes/webkit/images/ogimage.png 2016-06-28 18:08:59 UTC (rev 202576)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/images/ogimage.png 2016-06-28 18:12:23 UTC (rev 202577)
Property changes on: trunk/Websites/webkit.org/wp-content/themes/webkit/images/ogimage.png
___________________________________________________________________
Added: svn:mime-type
+image/png
\ No newline at end of property
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes