From d82f4db69d3315588d7cee03d0b13e3d0d812774 Mon Sep 17 00:00:00 2001 From: "jond@apple.com" Date: Tue, 29 Mar 2016 19:40:11 +0000 Subject: [PATCH] Support images above the title on webkit.org posts https://bugs.webkit.org/show_bug.cgi?id=155979 Reviewed by Timothy Hatcher. * wp-content/themes/webkit/functions.php: * wp-content/themes/webkit/single.php: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198788 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Websites/webkit.org/ChangeLog | 10 ++++++++++ .../wp-content/themes/webkit/functions.php | 20 ++++++++++++++++++++ .../webkit.org/wp-content/themes/webkit/single.php | 18 +++++++++--------- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/Websites/webkit.org/ChangeLog b/Websites/webkit.org/ChangeLog index b4ca54a..62edfe1 100644 --- a/Websites/webkit.org/ChangeLog +++ b/Websites/webkit.org/ChangeLog @@ -1,3 +1,13 @@ +2016-03-29 Jon Davis + + Support images above the title on webkit.org posts + https://bugs.webkit.org/show_bug.cgi?id=155979 + + Reviewed by Timothy Hatcher. + + * wp-content/themes/webkit/functions.php: + * wp-content/themes/webkit/single.php: + 2016-03-22 Jonathan Davis Allow the use of custom styles and scripts for blog posts diff --git a/Websites/webkit.org/wp-content/themes/webkit/functions.php b/Websites/webkit.org/wp-content/themes/webkit/functions.php index 99aa3c3..6ca3088 100644 --- a/Websites/webkit.org/wp-content/themes/webkit/functions.php +++ b/Websites/webkit.org/wp-content/themes/webkit/functions.php @@ -72,6 +72,26 @@ add_action('wp_head', function () { echo ''; }); +add_action('the_post', function($post) { + global $pages; + if (!is_single()) return; + + $content = $post->post_content; + if (strpos($content, 'abovetitle') === false) return; + if (strpos($content, 'post_title_img = substr($content, 0, strpos($content, ">\n") + 3); + $post->post_content = str_replace($post->post_title_img, '', $content); + $pages = array($post->post_content); +}); + +function before_the_title() { + $post = get_post(); + + if ( isset($post->post_title_img) ) + echo wp_make_content_images_responsive($post->post_title_img); +} + // Hide category 41: Legacy from archives add_filter('pre_get_posts', function ($query) { if ( $query->is_home() ) diff --git a/Websites/webkit.org/wp-content/themes/webkit/single.php b/Websites/webkit.org/wp-content/themes/webkit/single.php index bcf852c..2708c48 100644 --- a/Websites/webkit.org/wp-content/themes/webkit/single.php +++ b/Websites/webkit.org/wp-content/themes/webkit/single.php @@ -1,9 +1,9 @@ - +
id="post-"> -

+

-
- Read the rest of this entry >>

'); ?> +
+ Read the rest of this entry >>

'); ?> - Pages: ', '

', 'number'); ?> -
+ Pages: ', '

', 'number'); ?> +
- + - + endif; ?> \ No newline at end of file -- 1.8.3.1