@foreclosurefraudnews
I managed to get Gamezone to use WordPress’ post thumbnails feature.
I’d rather defer to someone who really knows PHP but I’ll post my findings anyway in case you want to play around with it yourself.
This example involves Gamezone’s index.php file.
Gamezone loads thumbnails via URLs that are set by the blogger using Custom Fields and assigns the thumbnail URL to a variable called $screen
:
<?php $screen = get_post_meta($post->ID,'screen', true); ?>
It then embeds that URL inside an img
HTML tag:
<img src="<?php echo ($screen); ?>" width="80" height="55" alt="" />
After some Google-fu and checking out some entries in the WordPress Codex, I replaced this:
<?php $screen = get_post_meta($post->ID,'screen', true); ?>
With this:
<?php $image_id = get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id,’thumbnail’, true); ?>
What it does is fetch the ID of the thumbnail that’s attached to the post and assigns it to $image_id
to be used later as a required parameter.
Then it gets the URL of the actual post thumbnail using wp_get_attachment_image_src
and assigns it to $image_url
. Note that wp_get_attachment_image_src
requires an ID, which is provided by $image_id
that we assigned earlier.
Then I replaced this:
<img src="<?php echo ($screen); ?>" width="80" height="55" alt="" />
With this:
<img src="<?php echo $image_url[0]; ?>" width="80" height="55" alt="" />
They do the same thing (I.e. Embed the URL of the thumbnail inside of the IMG HTML tag using php echo
.) except that the replacement code uses the URL derived from wp_get_attachment_image_src
.
I installed Gamezine on a defunct blog that was updated to WP v3.0.4, added a few featured images to some random posts, tested the new code and it worked. Gamezone theme was using post thumbnails set within WordPress.
I noticed that the Featured Posts slider would not function properly under Firefox, Chrome or Safari. Since I hadn’t made any changes to the glide.php script that controls it, this could be a theme issue.
Since I don’t know PHP, that’s about as far as I go. As mentioned, I defer to those with PHP experience. I thought I’d take a crack at it anyway for what it’s worth.