kevjo
Forum Replies Created
-
Forum: Themes and Templates
In reply to: [Theme: Hatch] Change default size of featured image in a post?[ Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still – use the pastebin ]
These instructions detail how to get portrait oriented photos in a post. I did the following to create a 640×966 featured image (note: I am a developer):
1. created a post template for when I want to feature vertical pictures and replaced the get_image code with:
<?php if ( current_theme_supports( 'get-the-portrait' ) ) get_the_portrait( array( 'meta_key' => 'Thumbnail', 'size' => 'single-thumbnail', 'link_to_post' => false, 'image_class' => 'featured', 'attachment' => false, 'width' => 640, 'height' => 966, 'default_image' => get_template_directory_uri() . '/images/single_image_placeholder.png' ) ); ?>2. I modified the functions.php page to include:
add_theme_support( 'get-the-portrait' ); add_action( 'init', 'hatch_portrait_sizes' ); function hatch_portrait_sizes() { add_image_size( 'archive-thumbnail', 220, 150, true ); add_image_size( 'single-thumbnail', 640, 966, true ); }3. I created an extension file in /library/extensions called get_the_portrait.php and replaced every instance of the get_the_image with get_the_portrait.
4. I added the below to /library/hybrid.php:
/* Load the Get the Portrait extension if supported. */ require_if_theme_supports( 'get-the-portrait', trailingslashit( HYBRID_EXTENSIONS ) . 'get-the-portrait.php' );5. I re-attached the featured image to the post.
Complicated, but voila! It worked.
These instructions detail how to get portrait oriented photos in a post. I did the following to create a 640×966 featured image (note: I am a developer):
1. created a post template for when I want to feature vertical pictures and replaced the get_image code with:
<?php if ( current_theme_supports( ‘get-the-portrait’ ) ) get_the_portrait( array( ‘meta_key’ => ‘Thumbnail’, ‘size’ => ‘single-thumbnail’, ‘link_to_post’ => false, ‘image_class’ => ‘featured’, ‘attachment’ => false, ‘width’ => 640, ‘height’ => 966, ‘default_image’ => get_template_directory_uri() . ‘/images/single_image_placeholder.png’ ) ); ?>
2. I modified the functions.php page to include:
add_theme_support( ‘get-the-portrait’ );
add_action( ‘init’, ‘hatch_portrait_sizes’ );
function hatch_portrait_sizes() {add_image_size( ‘archive-thumbnail’, 220, 150, true );
add_image_size( ‘single-thumbnail’, 640, 966, true );
}3. I created an extension file in /library/extensions called get_the_portrait.php and replaced every instance of the get_the_image with get_the_portrait.
4. I added the below to /library/hybrid.php:
/* Load the Get the Portrait extension if supported. */
require_if_theme_supports( ‘get-the-portrait’, trailingslashit( HYBRID_EXTENSIONS ) . ‘get-the-portrait.php’ );5. I re-attached the featured image to the post.
Complicated, but voila! It worked.