Display The Thumbnail Of An Image (file)
As we all know, Wordpress automatically takes an uploaded image and duplicates into multiple image sizes. I'd like to be able to call the thumbnail of an associated event into my event_list template.
Help would be appreciated - thanks!
11 Answers
I've never liked timthumb. You might try using this wordpress function:
http://codex.wordpress.org/Function_Reference/wp_get_attachment_image
This assumes that Pods assigns an attachment id when a file is uploaded. I haven't tried it so I can't say for sure whether it does.
You might also try:
http://www.maverick.it/en/tech/create-thumbnails-using-wordpress-built-in-functions
Try http://www.darrenhoyt.com/2008/04/02/timthumb-php-script-released/
Thanks for the tip about timthumb. I have been trying to set it up for pods for hours now but can't seem to get it to work.
After having followed instructions on multiple forums - set the timthumb folder permission to 755 and file to 644 as well asked hostgator to whitelist my domain (all these have been specific to hostgator as recommended by various forums) but the thumbnails still don't show, just the alt tag. Removing the timthumb script call in Firebugs shows the original image so I know that the path is correct. Any advice would be great! The link where this can be checked is http://buzzr.in/deals/ha-moving-sale (for testing, I have hardcoded the image link).
I am wondering if there is some kind of incompatibility with pods and Timthumb. If anyone has been able to get timthumb and pods working, please help me out. Thanks!
Have you tried using Timthumb on your local machine?
Unfortunately, I don't have a local setup (wouldn't know how to go about setting it up, I'm just starting out with all this :))
Thanks for the tip @mpvanwinkle. Ill give these a try.
I think I read somewhere that assigning thumbnails the way wp does it has not been added to pods yet.
I think using the built in resize functions is only possible with images linked to a post in WP (atleast according to the author of the blog link you recommended).
I tried using this function but am getting an error (http://buzzr.in/dealslist2)
The code that I am using (in a display helper is) <pre> $thumb = image_resize($value,25,25,true); $imagetag2='<img src="'.$thumb.'" alt="int">'; echo ($imagetag2); </pre> where image_resize is the internal function I have referenced the image api using require_once(ABSPATH . '/wp-admin/includes/image.php'); in functions.php
Any clues as to what I can try next?
Thanks.
@kunal17 - For starters, check your error log to see if there's anything in there. Then, try to also include the following above your "image.php" include:
<pre>require_once(ABSPATH . '/wp-includes/media.php');</pre>
image.php contains some image manipulation functions, but media.php is the file that contains image_resize().
Thanks for the suggestion. I tried that but I still get this error:
Catchable fatal error : Object of class WP_Error could not be converted to string in <b>/home/kunal17/public_html/buzzr/wordpress/wp-content/plugins/pods/core/Pod.class.php(302) : eval()'d code</b>
Hi.. when uploading a image from a pod entry, wordpress automatically generates 3 sizes. I have a solution for displaying them. Wordpress names these files like this: NAME-IMG-50x50.jpg (50x50 is the specified size at settings > media).
You can display this image like this: <img src="<?php echo substr($pod_image, 0 , -4);?>-50x50.jpg">
$pad_image is the var for get_field('NAME OF FIELD');
substr 0, -4 deletes the last 4 digits from your string. Than simply add the size.jpg and your done!
Hope this is helpfull..
There's an alternate way to do this using built-in WP function "wp_get_attachment_image_src":
<?
$oProjects->fetchRecord());
//change "image" for your file filed name, but leave ".ID" after it
$iImageID = $oProjects->get_field('image.ID');
//last parameter can be thumbnail, medium, large or full
$arImage = wp_get_attachment_image_src($iImageID,'large');
$strImageSrc = $arImage[0];
$iImageWidth = $arImage[1];
$iImageHeight = $arImage[2];
?>
<img src="<?php echo $strImageSrc; ?>" height="<?php echo $iImageHeight; ?>" width="<?php echo $iImageWidth; ?>" />
I think this is preferable because it doesn't hard-code the image dimensions you're using. In the above example, if you changed your thumbnails from 50X50 to 75X75 in the WP Admin > Settings > Media page, the code would break, whereas it will still work using this technique.
edited May 28 '10 at 2:02
