Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #83427
    Mouvance web
    Member

    Hi,
    Sorry for my english and thank you very much for your work and all your themes. I’d like to know how to add a new image size on free catch responsive theme. I tried this code (and other) but it didn’t work, the servor failed :

    if ( function_exists( 'add_image_size' )) {
    	add_image_size( 'header-size', 1200, 300, false );
    }
    add_filter('image_size_names_choose', 'my_image_sizes' );
    function my_image_sizes($sizes) {
    	return array_merge ( $sizes, array(
    	'header-size' => __( 'Dimensions de l'image d'en-tete'),
    	));
    }

    I wrote it in the functions.php file of my child theme. My aim is to have a new image size for my header picture. I don’t know if it is necessary to add code in the header.php file.
    Thank you!

    #83443
    Mahesh
    Participant

    Hi @Mouvance web,

    I didn’t get what you mean by header-size image size. Where do you want to actually use it? Please clarify more.

    Regards,
    Mahesh

    #83453
    Mouvance web
    Member

    I subsitute the slider by one main image in the header. I would like that images download in #header-featured-image be systematically resized, 1200px for the width, 300px for the height.
    Currently, images are resized at 1200px for width, 400px for height. I know that I can resize images manually, but it’s important that it be computerized. I hope I have been clear…Thank you!

    #83458
    Mahesh
    Participant

    Hi @Mouvance web,

    Thank you for the clarification.
    For that you need to create a child theme. Please visit this LINK to find more details on creating the child theme. Then in child theme’s functions.php add the following function.

    function catchresponsive_custom_header() {
    
    	$options 	= catchresponsive_get_theme_options();
    
    	if ( 'light' == $options['color_scheme'] ) {
    		$default_header_color = catchresponsive_get_default_theme_options();
    		$default_header_color = $default_header_color['header_textcolor'];
    	}
    	else if ( 'dark' == $options['color_scheme'] ) {
    		$default_header_color = catchresponsive_default_dark_color_options();
    		$default_header_color = $default_header_color['header_textcolor'];
    	}
    
    	$args = array(
    		// Text color and image (empty to use none).
    		'default-text-color'     => $default_header_color,
    
    		// Header image default
    		'default-image'			=> get_template_directory_uri() . '/images/headers/buddha.jpg',
    
    		// Set height and width, with a maximum value for the width.
    		'height'                 => 300,
    		'width'                  => 1200,
    
    		// Support flexible height and width.
    		'flex-height'            => true,
    		'flex-width'             => true,
    
    		// Random image rotation off by default.
    		'random-default'         => false,
    
    		// Callbacks for styling the header and the admin preview.
    		'wp-head-callback'       => 'catchresponsive_header_style',
    		'admin-head-callback'    => 'catchresponsive_admin_header_style',
    		'admin-preview-callback' => 'catchresponsive_admin_header_image',
    	);
    
    	$args = apply_filters( 'custom-header', $args );
    
    	// Add support for custom header
    	add_theme_support( 'custom-header', $args );
    
    }

    Regards,
    Mahesh

    #83460
    Mouvance web
    Member

    It’s perfect, it works!!!!I didn’t need color and default image arguments, but the other part is exactly what I need! Thank you very much,
    Regards,
    Mouvance Web

    #83649
    Mahesh
    Participant

    Hi @Mouvance web,

    Thank you for your appreciation.

    Regards,
    Mahesh

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Add image size’ is closed to new replies.