I'm using a customized version of the Twenty Eleven theme. I want to set a class on the body
based on which random header image is displayed. Is there some function that allows me to get the name of the custom header image that will be displayed? My goal is to style the text / background / colors based on the image being displayed.
Edit: I used Brian's answer, placing the $header_image
code before the <body>
tag, and also made some changes in header.php. I had to comment out the existing call to get_header_image()
:
// Check to see if the header image has been removed
//$header_image = get_header_image();
I also changed the header img
tag to use the $header_image
variable instead of using a call to header_image()
to get the file path:
<img src="<?php /*header_image();*/ echo $header_image; ?>"
width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>"
alt="" />