Pro Theme Design Forum » Mimbo Pro » Technical Help
making get_post_image get the original image file
|
I'd like to have the home page featured post image thumbnail be generated from the original full size image instead of from the size that was placed into the post. The get_post_image function, if I understand correctly, looks for images associated with a post -- either by attachment or by custom fields. It then runs that image through the TimThumb script to make a thumbnail at the dimensions coded into the template. When get_post_image finds an attached image, it generates the feature thumbnail using, as its source, the size of the image as placed into the post. For example, if I placed my image into the post at a thumbnail size of 150x150, that size will be the starting point for making the home page featured image for that post. If the home page feature image size I want is larger than 150x150, then I'm out of luck, because the source image is smaller than that, and TimThumb -- wisely -- won't enlarge images (at default settings). I've modified my template to have a relatively large feature image thumbnail on the home page, but it looks like the only way I can fill that space is if the images in my posts are placed at at least the same size I want on the home page, or if I use the custom field option. Is there an easy mod I can make to the get_post_image function that will make it use the full size image as its source? BTW, thanks for a great theme. : ) |
|
|
Hmmm... interesting problem. Not sure how this would work though. Will have a think about this. I guess I can see this being a bigger and bigger problem so I will add it to my todo list so I look into it in the future. As a short term solution I am not sure of any way to do what you want to do, I guess we'd need to somehow scan the attachments and see if there are larger versions, but I don't see this being that straight forward. If you have any ideas how we could sort it out that please do let me know. |
|
Well, I was testing the "get_post_image" function a little more and found something strange: wp_get_attachment_image_src is ignoring the $size parameter. So in this: "medium" is ignored. No matter what I put in there — "medium," "large," "full" — it uses the size of the image placed in my post to generate the feature image. So if the size in my post is smaller than what I want for the feature image, there's a problem. If I place my image into the post at a "thumbnail" size of 100x100px, then that's the size that will be used to generate the feature image (unless I've used a custom field to define the image). BUT, if I disable the part of the function that checks for custom fields (and the regex section that follows), then the $size parameter is correctly applied to wp_get_attachment_image_src. (I made sure that my post didn't have a custom field for the image.) Why the "check for custom fields" section interferes with the size parameter, I don't know, but this offers a way around my problem, because I can set the size parameter in the function to "large," and TimThumb will use that size as the source instead of the thumbnail. As long as I don't try to set the image using a custom field. |
|
|
that's some interesting info right there. I think it's given me a couple of ideas for places that I could look at to see if I can work out the types of things that could be done to improve this Thanks for the working this out - it helps a lot. I will let you know when I work out what the issue might be. |
Reply
You must log in to post.
not a support question