Support images above the title on webkit.org posts
authorjond@apple.com <jond@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Mar 2016 19:40:11 +0000 (19:40 +0000)
committerjond@apple.com <jond@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Mar 2016 19:40:11 +0000 (19:40 +0000)
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
Websites/webkit.org/wp-content/themes/webkit/functions.php
Websites/webkit.org/wp-content/themes/webkit/single.php

index b4ca54a..62edfe1 100644 (file)
@@ -1,3 +1,13 @@
+2016-03-29  Jon Davis  <jond@apple.com>
+
+        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  <jond@apple.com>
 
         Allow the use of custom styles and scripts for blog posts
index 99aa3c3..6ca3088 100644 (file)
@@ -72,6 +72,26 @@ add_action('wp_head', function () {
         echo '<script type="text/javascript">' . $script . '</script>';
 });
 
+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, '<img') !== 0) return;
+
+    $post->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() )
index bcf852c..2708c48 100644 (file)
@@ -1,9 +1,9 @@
 <?php get_header(); ?>
 
-       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
+    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
 
         <article <?php echo post_class(); ?> id="post-<?php the_ID(); ?>">
-                       <h1><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h1>
+            <h1><?php before_the_title(); ?><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h1>
             <div class="byline">
                 <p class="date"><?php the_time('M j, Y')?></p>
                 <p class="author">by <span><?php the_author() ?></span></p>
                 <?php endif; ?>
             </div>
             
-                       <div class="bodycopy">
-                               <?php the_content('<p class="serif">Read the rest of this entry &gt;&gt;</p>'); ?>
+            <div class="bodycopy">
+                <?php the_content('<p class="serif">Read the rest of this entry &gt;&gt;</p>'); ?>
 
-                               <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
-                       </div>
+                <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
+            </div>
         </article>
         
         <nav class="navigation pagination" aria-label="Next/Last posts">
             <?php next_post_link('%link', 'Newer Post <span>%title</span>'); ?>
         </nav>
 
-       <?php //comments_template(); // No comments ?>
+    <?php //comments_template(); // No comments ?>
 
-       <?php endwhile; else:
+    <?php endwhile; else:
         include('444.php');
-       endif; ?>
+    endif; ?>
 
 <?php get_footer(); ?>
\ No newline at end of file