After creating a child theme which is made of style.css
only (base on twentyeleven
), the time has come to replace the images.
I found this great tip for accomplishing this by hacking the functions in twentyeleven
but my main concern is minimizing work after a WordPress update.
I thought of simply replacing the images in /wp-content/themes/twentyeleven/images/headers
(while keeping the original names as came with twentyeleven
) but is this better?
It looks like either way I will have re-apply my customizations after updating WordPress in the future.
Is there a way to replace the 8 images, for a child theme, and still maintain the changes after an update?
I am never sure about ‘optimal approach’ – however, I am using this in the functions.php in a child theme of Twenty Eleven
//deregister the header images of Twenty Eleven, and register a few new RAW header images//
add_action( 'after_setup_theme', 'raw_theme_header_images', 11 );
function raw_theme_header_images() {
unregister_default_headers( array( 'wheel', 'shore', 'trolley', 'pine-cone', 'chessboard', 'lanterns', 'willow', 'hanoi' ) );
$folder = get_stylesheet_directory_uri();
register_default_headers( array(
'coleslaw' => array(
'url' => $folder.'/images/headers/coleslaw.jpg',
'thumbnail_url' => $folder.'/images/headers/coleslaw-thumb.jpg',
/* translators: header image description */
'description' => __( 'Coleslaw', 'twentyeleven' )
),
'tomato_and_sprouts' => array(
'url' => $folder.'/images/headers/tomato_and_sprouts.jpg',
'thumbnail_url' => $folder.'/images/headers/tomato_and_sprouts-thumb.jpg',
/* translators: header image description */
'description' => __( 'Tomato and Sprouts', 'twentyeleven' )
)
)
);
}
the new images are in an /images folder in the child theme.