Generating Thumbnails For WordPress Magazine Style Themes
I had earlier posted some tips to automatically generate thumbnails for magazine styled themes. I was working on the Gazzete Theme from Woothemes which needed some changes to be done. Woothemes has the image resizer option but I had some other modifications done so I could not use that.
The best thing to depend is the phpthumb plugin for wordpress. Once you have this plugin activated, you can use the thumbnail generation plugin to create thumbnails for your blog with the needed sizes.
What I have done is to get the image URL from the blog post. We can use different function to get the attached images from a post, but I was using the Autoblogging tool for doing the posts and images were from different other websites. So what I do is scan the post for image URL using this function
|
1 |
<span style="color: #0000ff">function</span> getImageUrl() { |
|
1 |
$content = get_the_content(<span style="color: #006080">''</span>); |
|
1 |
$content = apply_filters(<span style="color: #006080">'the_content'</span>, $content); |
|
1 |
preg_match(<span style="color: #006080">"/<img.+?src=\"(.+?)\"/"</span>,$content,$match); |
|
1 |
<span style="color: #0000ff">return</span> $match[1]; |
|
1 |
} |
Once I get the image URL, I can display the image by generating a thumbnail image on my server.
|
1 |
<img src=<span style="color: #006080">"<?php echo getphpthumburl($kishimg, 'w=100&h=57&zc=1'); ?>"</span> |
The getphpthumburl function is from the phpthumb plugin which can be used anywhere on your blog template.
If you know any hack, please feel free to shout.
