I'm trying to use Wordpress' built-in thumbnailing and image re-sizing in my Wordpress 2.9.2 installation. I'm trying to get various sizes (post listing/results 160x160 & "single.php" 618x150) and for some reason the single.php one works, but only half way. Not sure if I'm doing something wrong here.
I have it working…sorta. I’m totally stuck and there seems to be a lack of documentation on the Codex for this feature so here goes.
The small 160×160 thumbnail for article listings/search views works fine. It crops it, all’s groovy. The issue comes when I go to format the image for the single.php article details view. It crops, but then scales down even further for some reason.
Screenshot:
http://c1319072.cdn.cloudfiles.rackspacecloud.com/4-15-2010%204-56-46%20PM.png
NOTE: every time I re-test this I’m completely deleting the image from the media section and re-uploading the image entirely. I also have the re-create thumbnails plugin so I know it’s not caching.
Here is my code included in "functions.php". This will help in debugging.
add_theme_support( ‘post-thumbnails’ );
set_post_thumbnail_size( 160, 160, true ); // Normal post thumbnails
add_image_size( ’single-post-thumbnail’, 618, 150, true ); // Permalink thumbnail size
I just wrote a detailed post regarding the wordpress post thumbnails a few days ago, you might find it very useful as it is very detailed.
How to use Post Thumbnails Feature in Wordpress!
I had similar problems trying to get it to work and finally went with TimThumb.
I simply love it's simplicity and effectiveness. It works great, has cache capabilities and it's fast and easy.
Official site (includes tutorial): http://www.darrenhoyt.com/2008/04/02/timthumb-php-script-released/
And here's an example on how I call it in my Wordpress:
<img src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "image", $single = true); ?>&h=75&w=75&zc=1&q=90" alt="<?php the_title(); ?>" />
(loads the image URL from a custom field of the post and resizes it to 75x75 and 90% quality)
Related
I have an installation of Magento that integrates with Wordpress using the Fishpig Wordpress module.
As most WP users will know, when uploading an image Wordpress will create resized versions referencing the dimensions set in Media Settings (e.g. Thumbnail Size, Medium Size and Large Size). It also creates images for each custom thumbnail size you specify (e.g. via functions.php).
It appears as though the Fishpig Magento module only uses the Thumbnail image size.
Unfortunately I need to be able to display different sizes of the same image (i.e. the resized versions that Wordpress creates) on different pages. For example, the category page will display a small version, the post view page will display a larger version.
I was wondering if anyone has had any experience retrieving the other resized images via this module as I can't find much documentation on it (or if it's even possible with this module as I also couldn't see any code that would suggest this functionality).
Greatly appreciate the help.
I had the same issue...I wanted to create a recent posts widget and Fishpig has that well documented, but they didn't show an example of how to pull the featured image for the post.
But I found the answer in: /app/design/frontend/base/default/template/wordpress/post/list/renderer/default.phtml:
<?php if ($featuredImage = $post->getFeaturedImage()): ?>
<div class="featured-image left">
<img src="<?php echo $featuredImage->getAvailableImage() ?>" alt="<?php echo $this->escapeHtml($post->getPostTitle()) ?>"/>
</div>
<?php endif; ?>
You can change "getAvailableImage" to anyone of these to pull the different images sizes that wordpress produces:
getThumbnailImage()
getMediumImage()
getLargeImage()
getFullSizeImage()
getPostThumbnailImage()
getAvailableImage()
getImageByType($type = 'thumbnail')
Hope this helps!
Have try to do using below code. and working fine for me..
echo $featuredImage->getData('guid');
this is my first time posting on this site so apologies if the question isn't totally appropriate but I'm building a portfolio site for my brother who is a composer and he needs his music library to be able to be checkbox filter-able. The problem is that when I conduct a search with filters, the results show only the excerpt, and not the audio player like I need.
Library page displaying the full posts with audio player
Search results page showing just the post title and nothing else
Also, excuse the sheer crudeness of the site. I just started it this morning... Thanks in advance!
To show the full content you have to use the_content function, in your search.php file replace the following
<?php the_excerpt(); // partial content ?>
with
<?php the_content(); // full content ?>
Also remember. the_excerpt function strips out all HTML tags so it could be a problem, you can read this article.
I have created a blog using wordpress, it has been developed on my localhost and the theme is the LUGADA Theme found here.
I want to add a logo which is bigger than the specfied size in theme that has been specified as 300 x 70 by the designer. When I try and upload a new logo using the facility they provide, it forces me to crop the image to their required size, how do I get around this?
I looked at header.php and found this:
<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
I have tried taking HEADER_IMAGE_WIDTH and HEADER_IMAGE_HEIGHT out but the upload facility forces me to crop the image
I have considered hardcoding the logo in but want it to still be available when I change the theme. I have also tried tracking down header_image(), which I found in wp-includes/theme.php but could not work out what to do from there.
Could someone please advise how I put a logo sized to my requirements in please?
There are a couple of tweaks to this theme that I would recommend, and they should achieve the results you're looking for.
First, the theme is currently using a deprecated method (add_custom_image_header) in order to allow you to upload your logo. Let's temporarily stop that, use a newer function, and if you're happy with the results you can follow my instructions to clean up the code.
Open functions.php and find lines 135, 136, and 176 and comment them out:
//define('HEADER_IMAGE_WIDTH', 300); // use width and height appropriate for your theme
//define('HEADER_IMAGE_HEIGHT', 300);
//add_custom_image_header('lugada_header_style', 'lugada_admin_header_style');
Add the following code after line 176:
$header_defaults = array(
'width'=>300,
'height'=>200,
'flex-height'=>true,
'flex-width'=>true
);
add_theme_support( 'custom-header', $header_defaults );
In your header.php file, go ahead and replace line 68 with this code (remove the width and height attributes):
<img src="<?php header_image(); ?>" alt="" />
Some notes on this code...
You're now using a newer method for the custom header logo. This means you'll have fewer problems upgrading WordPress in the future
Your now using flexible height and width so you can crop however you wish
You can change those height and width values to whatever you wish (for defaults)
You can find more information about the usage of add_theme_support here, and you may find even more helpful options.
If you're happy with the results and want to clean up the code you can delete lines 135, 136, and 176 and delete the two functions named lugada_header_style and lugada_admin_header_style.
Have fun!
How to take on a problem in WordPress admin editing.
I'd like to edit an edit-category admin panel to add a featured image to it (just like in posts), but I'm a bit indecisive since a lot of people use a custom field with static path to a photo, but I'm wondering is there a way to do it better(enable some wp hook and such).
Can someone point me in the right direction?
Thanks for the plugin it seems good, but i have one additional problem. It seems i have a lack of knowledge on how to query an object [category] so i can apply filters, hope im making some sense. This is done on my home.php. all dumps are null
<?php get_header();
$listcat = get_categories('hide_empty=0');
foreach($listcat as $x){
$img = apply_filters( 'taxonomy-images-queried-term-image', '');
var_dump($img);
}
get_footer(); ?>
The same code works with no problems if i stick it in category.php. Any ideas? :)
i've used several times the plugin "Taxonomy Images". it works with multi-language wp installs too.
link with instruction: http://wordpress.mfields.org/plugins/taxonomy-images/
I've been working with WordPress built-in functions for a couple of days now and got everything working this far. However, I am trying to find a solution to only fetch posts that have thumbnails into an array/object.
I have already checked out the Wordpress function references, but have yet not found any solution. How can I achieve this?
The Wordpress codex is pretty sparse on this topic. In WordPress 2.9, "Post Thumbnails" were added. In 3.0, they seem to have been renamed "Featured Images." In your theme, you can easily check to see whether or not a post has a featured image.
Within the main have_posts() loop in your theme, you can:
<?php
if (has_post_thumbnail()) {
/* Post has a thumbnail */
}
?>