Title: [198788] trunk/Websites/webkit.org
Revision
198788
Author
[email protected]
Date
2016-03-29 12:40:11 -0700 (Tue, 29 Mar 2016)

Log Message

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:

Modified Paths

Diff

Modified: trunk/Websites/webkit.org/ChangeLog (198787 => 198788)


--- trunk/Websites/webkit.org/ChangeLog	2016-03-29 19:04:02 UTC (rev 198787)
+++ trunk/Websites/webkit.org/ChangeLog	2016-03-29 19:40:11 UTC (rev 198788)
@@ -1,3 +1,13 @@
+2016-03-29  Jon Davis  <[email protected]>
+
+        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  <[email protected]>
 
         Allow the use of custom styles and scripts for blog posts

Modified: trunk/Websites/webkit.org/wp-content/themes/webkit/functions.php (198787 => 198788)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/functions.php	2016-03-29 19:04:02 UTC (rev 198787)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/functions.php	2016-03-29 19:40:11 UTC (rev 198788)
@@ -72,6 +72,26 @@
         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() )

Modified: trunk/Websites/webkit.org/wp-content/themes/webkit/single.php (198787 => 198788)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/single.php	2016-03-29 19:04:02 UTC (rev 198787)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/single.php	2016-03-29 19:40:11 UTC (rev 198788)
@@ -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="" echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h1>
+            <h1><?php before_the_title(); ?><a href="" 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>
@@ -12,11 +12,11 @@
                 <?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">
@@ -24,10 +24,10 @@
             <?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
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to