Hmmm….Benjamin, that’s an interesting question, and I can really only guess on the answer. If you do this, please note that any time this plugin is updated, your changes will be lost and you will have to redo them.
In the current version of Display Featured Image for Genesis, you’ll want to look in the class-displayfeaturedimage-output.php file. Line 41 looks like this:
$item->original = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'original' );
You’ll want to change that, maybe to something like:
$item->original = wp_get_attachment_image_src( MultiPostThumbnails::the_post_thumbnail( get_post_type(), 'header-image' ) );
The reason I say “in the current version” is because I’m about to release the next version of the plugin, which has some great new features but has also undergone some restructuring. In the new version, which you can go ahead and download from GitHub if you want to experiment with that, the variables are all stored in the file class-displayfeaturedimage-common.php. The line to look for will be the same content.
I plan on pushing the new version out in the next few days–at this point, I think it’s stable and won’t be changing, but there may be a tweak or two. If you’re comfortable downloading from GH, I would go ahead and use this version, instead of 1.1.3. Good luck! HTH
Thank you for the nice reply which i was very happy about.
I tested the provided code. And it worked.. somewhat 🙂 The post used the second featured image, but it used it four times (=four full width images aligned one over the other). And it pushed all the four images above what I think is called the genesis header hook.
I will look into this tomorrow morning, but right now I wonder why it should take four images (and not 3 or 5?). Mhm.
That is really strange. The plugin only outputs the image once. I wonder if we need to add in the post ID argument to the new line?
$item->original = wp_get_attachment_image_src( MultiPostThumbnails::the_post_thumbnail( get_post_type(), 'header-image', $post->ID ) );
The other thing is that you may need to do some testing to see if the wp_get_attachment_image_src function works with the output from MultiPostThumbnails. I don’t think this is the issue, since you are getting the image, rather than it not displaying at all, but it might be something to check out. Basically, the goal is to narrow down to just the URL of the featured image, but using this function, we are able to use some of the necessary metadata from it as well, to make sure the output behaves the way we want.
I am a bit sorry to ask, but how would I test the function you mentioned? I really do not know php other than I am lucky enough to find the right code line.
After checking the elements with google chrome I came across one thing, which might help.
When the image is displayed correctly the hierarchy looks something like this:
body-> div site container -> div big-leader -> image
After applying the new code (the one with the four images) I saw that all the images are written directly into the body. The div big-leader container doesnt appear at all. Personally I do not know what this could mean.
I also checked another plugin, which is called “Genesis custom header” I think. In this plugin there is the option to attach an image to the header instead of using the featured image. So exactly what I try to achieve. This is done via a simple upload button which makes it convient enough for us non-coders. I like the optical style of your plugin much better, though. Maybe an option like this would be something for an update in the feature?
Hey Benjamin!
The idea for this plugin is really to keep things as simple as possible for the end user, which is why I’m using the built in featured image option. I intentionally do not want to add new things that have to be done every time to make something look the way it should.
One suggestion I would make is that maybe you should switch how you are wanting to use the two plugins–use the MultiPostThumbnails plugin for things like menu images with overlays, and keep the main featured image for this. Since I assume you are having to do the code work for the MultiPostThumbnails output anyway, you could theoretically do that without writing in this plugin.
However, I did some looking into the plugin and what’s going on is that you need to access a different function to get the MultiPostThumbnails data needed. The original function from the wiki actually outputs the image, so it’s not going to work. Instead, you want to use get_post_thumbnail_id from that plugin, which returns the appropriate file information.
You can comment out the $item->original line in the elseif ( is_singular... section and try replacing it with these two lines:
$headerimage = MultiPostThumbnails::get_post_thumbnail_id( get_post_type(), 'header-image', $post->ID ); // gets the header-image id from the plugin
$item->original = wp_get_attachment_image_src( $headerimage, 'backstretch' ); // retrieves the source info (URL, width, etc.) from the header-image
The problem is that the conditional is checking the post’s featured image data to get to this point (if the featured image is small, then my plugin won’t use it, which is intentional), so really, you’ll probably need to figure out how to add in a new conditional to check your header-image instead of the featured image/post thumbnail. It should be doable, but it’s beyond the scope of what I can offer through this forum.
Good luck!