• Resolved djj_

    (@djj_)


    It’s pretty neat what the theme does, displaying a thumbnail if the post includes images. How would I go on setting some image as a default, in case the post doesn’t have any?

    I found some guides on this subject but if I understood correctly, this Hybrid framework complicates matters a bit.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Theme Author Sami Keijonen

    (@samikeijonen)

    You do it like this.

    add_filter( 'get_the_image_args', 'my_get_the_image_args' );
    
    function my_get_the_image_args( $args ) {
    
    	$args['default_image'] = trailingslashit ( get_stylesheet_directory() ) . 'images/example.png';
    
    	return $args;
    }
    Theme Author Sami Keijonen

    (@samikeijonen)

    Sorry there were little mistake in code snippet. Here it is again and in more detail. Put this code in child theme functions.php.

    This goes inside setup function.

    add_filter( 'get_the_image_args', 'my_get_the_image_args' );

    And this outside.

    function my_get_the_image_args( $args ) {
    
    	$args['default_image'] = trailingslashit ( get_stylesheet_directory_uri() ) . 'images/example.png';
    
    	return $args;
    
    }
    Thread Starter djj_

    (@djj_)

    Thank you! That’s real elegant (and almost stupidly simple..) I am still learning, that much is obvious.

    Theme Author Sami Keijonen

    (@samikeijonen)

    All I can say that almost everything is filterable in the theme and naturally in Hybrid Core.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Default featured image’ is closed to new replies.