WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Changing images in a theme (6 posts)

  1. headless99
    Member
    Posted 1 year ago #

    I am using the Twenty Eleven theme and want to replace the default header images with my own images. In twentyeleven\images I have added my own for testing but they do not appear on the web page when I load it; I then removed the original images but mine still don't show.
    I have looked at the code in header.php but can't see where the images location is coded so I can verify I am at least on the right path.
    Can anyone help me with this?

    Cheers

    Chris

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    First up - don't edit 2011, your changes will be lost
    http://vudu.me/child for help with that - you need a child theme to make your changes

    As for your question:
    http://vudu.me/ph
    Here's some info on how to remove the default header images, and use your own through a child theme

  3. headless99
    Member
    Posted 1 year ago #

    Thanks Rev. Voodoo

    I had found the functions.php after I posted my query and was playing around with it.
    I was not aware you could lose changes made to a WordPress theme so I will take your advice and instructions and create a child-theme.

    Cheers for the help!!

    Chris

  4. headless99
    Member
    Posted 1 year ago #

    Hi Rev

    I'm working on unregistering the default image headers and registering my own; I have found two issues:

    1. As in my code below, I can only unregister three of the default header images in Twenty Eleven theme. If I try any more I get the following error:
    Parse error: syntax error, unexpected "T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/headless/public_html/wp-content/themes/twentyeleven-child/functions.php on line 53"
    The line number coincides with the fourth image.

    2. On the Appearance > Header page of my child theme, the thumbnails for my new registered images are not there; all I get is the identifying tag as well as the remaining five default images.

    While the images rotate randomly, when it gets to one of mine it is blank.

    Your thoughts appreciated - http://headless.id.au/

    '//ADD NEW DEFAULT HEADER
    function twentyelevenchild_header_in() {
    $dir = ('http://headless.id.au/wp-content/themes/twentyeleven-child');
    define( 'HEADER_IMAGE', 'http://headless.id.au/wp-content/themes/twentyeleven-child/images/trish&danika.jpg' );
    register_default_headers( array (
    'arizona' => array (
    'url' => "$dir/images/arizona.jpg",
    'thumbnail_url' => "$dir/images/arizona-thumbnail.jpg",
    /* translators: header image description */
    'description' => __( 'arizona', 'twentyeleven' )
    ),
    'new-york' => array (
    'url' => "$dir/images/new_york.jpg",
    'thumbnail_url' => "$dir/images/new-york-thumbnail.jpg",
    /* translators: header image description */
    'description' => __( 'new-york', 'twentyeleven' )
    ),
    'trish&danika' => array (
    'url' => "$dir/images/trish&danika.jpg",
    'thumbnail_url' => "$dir/images/trish&danika-thumbnail.jpg",
    /* translators: header image description */
    'description' => __( 'trish&danika', 'twentyeleven' )
    ),
    'the-bean' => array (
    'url' => "$dir/images/the-bean.jpg",
    'thumbnail_url' => "$dir/images/the-bean-thumbnail.jpg",
    /* translators: header image description */
    'description' => __( 'the-bean', 'twentyeleven' )
    ),
    ));
    }

    add_action( 'after_setup_theme', 'twentyelevenchild_header_in' );

    // REMOVE SOME DEFAULT HEADERS
    function twentyelevenchild_header_out() {
    unregister_default_headers( array(
    'wheel',
    'shore',
    'trolley')
    );
    }
    add_action( 'after_setup_theme', 'twentyelevenchild_header_out', 11 );'

  5. headless99
    Member
    Posted 1 year ago #

    Hi Rev
    Thanks for the asdvice so far..

    I'm working on unregistering the default image headers and registering my own; I have found two issues:

    1. As in my code below, I can only unregister three of the default header images in Twenty Eleven theme. If I try any more I get the following error:
    Parse error: syntax error, unexpected "T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/headless/public_html/wp-content/themes/twentyeleven-child/functions.php on line 53"
    The line number coincides with the fourth image.

    2. On the Appearance > Header page of my child theme, the thumbnails for my new registered images are not there; all I get is the identifying tag as well as the remaining five default images.

    While the images rotate randomly, when it gets to one of mine it is blank.

    Your thoughts appreciated - http://headless.id.au/

    '//ADD NEW DEFAULT HEADER
    function twentyelevenchild_header_in() {
    $dir = ('http://headless.id.au/wp-content/themes/twentyeleven-child');
    define( 'HEADER_IMAGE', 'http://headless.id.au/wp-content/themes/twentyeleven-child/images/trish&danika.jpg' );
    register_default_headers( array (
    'arizona' => array (
    'url' => "$dir/images/arizona.jpg",
    'thumbnail_url' => "$dir/images/arizona-thumbnail.jpg",
    /* translators: header image description */
    'description' => __( 'arizona', 'twentyeleven' )
    ),
    'new-york' => array (
    'url' => "$dir/images/new_york.jpg",
    'thumbnail_url' => "$dir/images/new-york-thumbnail.jpg",
    /* translators: header image description */
    'description' => __( 'new-york', 'twentyeleven' )
    ),
    'trish&danika' => array (
    'url' => "$dir/images/trish&danika.jpg",
    'thumbnail_url' => "$dir/images/trish&danika-thumbnail.jpg",
    /* translators: header image description */
    'description' => __( 'trish&danika', 'twentyeleven' )
    ),
    'the-bean' => array (
    'url' => "$dir/images/the-bean.jpg",
    'thumbnail_url' => "$dir/images/the-bean-thumbnail.jpg",
    /* translators: header image description */
    'description' => __( 'the-bean', 'twentyeleven' )
    ),
    ));
    }

    add_action( 'after_setup_theme', 'twentyelevenchild_header_in' );

    // REMOVE SOME DEFAULT HEADERS
    function twentyelevenchild_header_out() {
    unregister_default_headers( array(
    'wheel',
    'shore',
    'trolley')
    );
    }
    add_action( 'after_setup_theme', 'twentyelevenchild_header_out', 11 );'

  6. headless99
    Member
    Posted 1 year ago #

    All good!!

    I had typos in my unregister_default_headers plus my images were uploaded with a capitalised first letter whereas in the function they are called using all lower case.

    Thanks for the help!!

    Cheers

    Chris

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags