WordPress.org

Ready to get started?Download WordPress

Forums

Hatch
change the size of the first image in a post (10 posts)

  1. ojabierto
    Member
    Posted 2 years ago #

    Hi everyone,

    Like i said, i can't change the size of the first image in the posts (called "single-thumbnail featured" i think).

    Originaly, the image is like: 640x360px, and i would like to get it larger.

    Thank you.

    http://wordpress.org/extend/themes/hatch/

  2. mariannambet
    Member
    Posted 2 years ago #

    If you want to remove template size of any image/first iage, remove this line from post.php

    <?php hybrid_entry_class(); ?>

    You can then set size of image in each post individually via HTML view.

  3. ojabierto
    Member
    Posted 2 years ago #

    Thank you so much ! I'll try it right now.

  4. ojabierto
    Member
    Posted 2 years ago #

    Well, i just tried it & to be honest, this doesn't work very well with this theme. I only wish i can change the first image's size... But thanks again anyway.

  5. radhika
    Member
    Posted 2 years ago #

    @ojabierto

    you want to change the size of header image.

  6. radhika
    Member
    Posted 2 years ago #

    According your theme the header image is fixed in style.css template. you can edit here the width header-banner:

    #header-banner {
    	width: 68.08510638297872%; <--edit the image
    	float: right;
    }

    and edit the custom-width of image in function.php template of your theme.

    $args = array(
    		'width'         => 630, <-- edit the width
    		'height'        => 360,
    		'header-text'   => false,
    		'default-image' => trailingslashit( get_stylesheet_directory_uri() ).'images/header_default.png',
    		'uploads'       => true,
    	);
    	add_theme_support( 'custom-header', $args );
  7. stoatoffear
    Member
    Posted 1 year ago #

    Hi,
    This is what I did to control the size of the featured image in hatch:
    First of all, I hear it's bad to alter the theme code, so make sure you have a pristine copy of hatch and create a child theme. This is very easy. My child theme consists of a folder (in the themes folder) called hatch-child. Into hatch child I put a style.css file with:

    /*
    Theme Name: Hatch Child
    Description: Child theme for Hatch theme
    Author: stoatoffear
    Template: hatch
    */
    
    @import url("../hatch/style.css");

    Please bear in mind that the theme name "hatch" is case-sensitive.
    Next create a functions.php file in the hatch-child folder with the following, but altering the line at the bottom as you wish:

    <?php
    
    /**
    * @package Hatch Child
    * @subpackage Functions
    * @version 0.1
    * @author DevPress
    * @link http://devpress.com
    * @license http://www.gnu.org/licenses/gpl-2.0.html
    */
    
    /* Do theme setup on the 'after_setup_theme' hook. */
    add_action( 'after_setup_theme', 'hatch_child_theme_setup', 11 );
    
    function hatch_child_theme_setup() {
    
        /* Get action/filter hook prefix. */
        $prefix = hybrid_get_prefix();
    
        /* Custom image sizes */
        remove_action( 'init', 'hatch_image_sizes' );
        add_action( 'init', 'mytheme_image_sizes' );
    
    }
    
    function mytheme_image_sizes() {
    
    	add_image_size( 'single-thumbnail', 640, 360, true );
    /*alter this line to change the featured image size
    delete "true" to stop the image being cropped, or change the width and height. */
    }
    ?>

    Then activate the child theme in your site and voila! You will have to re-insert any images that were inserted before you activated the child-theme, plus the header image on the home page will also need to be re-done, and if you have a menu you will have to reactivate it.

    Check my site http://www.richardcalvert.com where you can see that the featured images are now not cropped, and insert themselves at the correct height - whatever that is.

    I am a newbie too, so be sure to point out any improvements! I haven't noticed any problems yet though.

  8. ojabierto
    Member
    Posted 1 year ago #

    Hi Richard,

    Thank you for share your experience here. Your technic sounds very interesting to me. But to be honest, i don't want to re-insert so many images. ;) (as you can see http://ojabierto.net/)

    So i think i'll keep my website with these cropped featured images.

    Anyway, i hope that your advice will help some people.

    Bye.

  9. stoatoffear
    Member
    Posted 1 year ago #

    ojabierto, you'd only have to reinsert your featured images, plus the main image on your home page.

  10. jasontaylor900
    Member
    Posted 1 year ago #

    I have learned a lot from the discussions. I will definitely benefited from the ideas

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags