• 0

wordpress: how i can post thumbnail?


Question

i have this code

<div class="blogPostImage">

<a href="<?php echo get_permalink(); ?>" class="img"><img src="<?php echo $themePath ?>includes/timthumb.php?src=<?php echo $postImage ?>&w=136&h=136&zc=1" width="136" height="136" alt="<?php the_title(); ?>" /></a>

with this code (<img src="<?php echo $themePath ?>includes/timthumb.php?src=<?php echo $postImage ?>&w=136&h=136&zc=1" width="136" height="136") i have to upload the image on my server and after use it as a thumbnail in home page. this code does not support external urls. how i can modified it in order to use the wordpress thumbnail function with external urls?

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

He was asking about Timthumb specifically and how it can be modified so that it can accept external images. :p

To the OP: When is the last time you've updated TimThumb? Some support for external sources like Flickr & YouTube were already added the--first addition being 12/30/09. It helps to stay updated with your scripts!

Download the latest source (updated 4/30/10):

http://code.google.com/p/timthumb/source/browse/trunk/timthumb.php

Link to comment
Share on other sites

  • 0

He was asking about Timthumb specifically and how it can be modified so that it can accept external images. :p

To the OP: When is the last time you've updated TimThumb? Some support for external sources like Flickr & YouTube were already added the--first addition being 12/30/09. It helps to stay updated with your scripts!

Download the latest source (updated 4/30/10):

http://code.google.com/p/timthumb/source/browse/trunk/timthumb.php

this doesnt turn the external images on my posts as thumbnails :(

Link to comment
Share on other sites

  • 0

this doesnt turn the external images on my posts as thumbnails :(

Are you expecting it to do it automatically? 'Cos the script isn't designed to do automatically convert any images in a post to a thumbnail. You actually have to include the timthumb URL in order to "turn" it into a thumbnail.

Alternatively, if you use the custom field for your thumbnails you can easily do something like this in your theme:

 &lt;?php if ( get_post_meta($post-&gt;ID, 'screenshot', true) ) { ?&gt;
							&lt;div class="screenshot"&gt;
                            	&lt;a href="&lt;?php the_permalink(); ?&gt;" rel="&lt;?php bloginfo('url');?&gt;/wp-content/uploads/screenshots/&lt;?php echo get_post_meta($post-&gt;ID, "screenshot", true); ?&gt;" title="&lt;?php the_title();?&gt;"&gt;
                            	&lt;img src="&lt;?php bloginfo('template_directory'); ?&gt;/scripts/timthumb.php?src=&lt;?php bloginfo('url');?&gt;/wp-content/uploads/screenshots/&lt;?php echo get_post_meta($post-&gt;ID, "screenshot", true); ?&gt;&amp;h=190&amp;w=200&amp;zc=1" alt="&lt;?php the_title(); ?&gt;" width="200" height="190" /&gt;&lt;/a&gt;
                            &lt;/div&gt;
					&lt;?php } ?&gt;

That snippet is included in the post loop on my index.php and of course the single.php. You can change it around to suit your likings.

Just remember that you need to create a custom field and whatever you label it is (perhaps thumbnails) you'll need to change that in the code above (for get_post_meta).

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.