Results 1 to 10 of 21
-
1st May 2011, 10:30 PM #1OPPure Awesomeness!
How to integrate Timthumb with wordpress
Firts step - Adding the "get image" function to the functions.php file:
----------------------------------------------------------------------
This code basically gives us the ability to fetch the first image on the post.
Code:function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = "/images/default.jpg"; } return $first_img; }
------------------------------------------
Code:function PostThumbURL() { global $post, $posts; $thumbnail = ''; ob_start();the_post_thumbnail();$toparse=ob_get_contents();ob_end_clean(); preg_match_all('/src=("[^"]*")/i', $toparse, $img_src); $thumbnail = str_replace("\"", "", $img_src[1][0]); return $thumbnail; }
--------------------------------------------------------------------
Original timthumb doesn't work with external hosts such as tinypic/lulzimg...etc, but here is a customized version I've been using
that does . You can get it from here: http://paste2.org/p/1394246 - Make a new file and name it timthumb.php and upload it to your
theme's folder.
This is gonna be tricky if you're not into coding, but just try to find the file(s) that return the content on the index/category pages/
archives...etc, then add this where you want the image to show up:
Code:<div class="post_thumb"> <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><img src="http://yourdomain.com/path/to/timthumb.php?src=<?php echo catch_that_image() ?>&w=100&h=100&zc=1" title="<?php the_title(); ?>" alt="<?php the_title(); ?>" /></a> </div>
your theme shows up the whole post and doesn't have the option to swith to excerpts).
Oh, and you need to create a cache folder in the same directory of the timthumb file and chmod it to 777.
Fourth step - Adding some css code:
--------------------------------------
Get your style.css file and add this somewhere in there:
Code:.post_thumb { padding: 0 10px 10px 0; float:left; }
Example from my site:
PS: I didn't code the functions, I found them on google and made them work together, good luck with the setup.RT Reviewed by RT on . How to integrate Timthumb with wordpress Firts step - Adding the "get image" function to the functions.php file: ---------------------------------------------------------------------- This code basically gives us the ability to fetch the first image on the post. function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); Rating: 5
-
18th May 2011, 08:17 AM #2Member
Hey Mr-R-T,
I removed this part cause it wasn't displaying internal images on the server...
Code:$host = $_SERVER["HTTP_HOST"]; $src = str_replace($host, "", $src); $host = str_replace("www.", "", $host); $src = str_replace($host, "", $src);
Btw why did you turn off cache check?
-
19th May 2011, 11:45 AM #3MemberWebsite's:
wrzscene.info watchfreetvseriesonline.comi tried this but had problems, can anyone help out here
http://www.besthostingforums.com/showthread.php?t=82831
-
20th May 2011, 12:12 PM #4Member
The script works for external sources, but I found out its not working on images hosted on the server itself. Like I said above, I just removed this one:
Code:$host = $_SERVER["HTTP_HOST"]; $src = str_replace($host, "", $src); $host = str_replace("www.", "", $host); $src = str_replace($host, "", $src);
-
20th May 2011, 08:30 PM #5
-
20th May 2011, 09:00 PM #6MemberWebsite's:
adultrls.org tankibazz.com niloy.netThanks For The Great Tips.
-
21st May 2011, 07:35 AM #7Member
Not really a php coder so my codes are really messy
But you can secure it a little by storing your sites in an array and doing something like this:
Code:strpos($src, $mysites);
But really I don't think this is secure as there are other ways to work around it. I'm still finding a better secure solution for the designated urls
-
7th Jun 2011, 10:16 PM #8Banned
here's the code in my functions.php file..
I don't really get Step 2. is it in timthumb.php? or stil in functions.php? Added timthumb.php in my theme's folder. chmod is 644..
also I don't really get where to put this:
Edit my Reading settings change it to summary and edited my style.css
but still not working..
any help please.
-
7th Jun 2011, 10:18 PM #9OPPure Awesomeness!
-
7th Jun 2011, 10:56 PM #10Banned
where should I put this code RT?
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Timthumb Not Working
By msk19994 in forum Server ManagementReplies: 4Last Post: 25th Oct 2012, 05:24 AM -
How Can I Integrate VBulletin Forum In Wordpress Blog Theme (Header/Footer)
By shubhank008 in forum WordpressReplies: 7Last Post: 24th Oct 2011, 06:20 AM -
[Hiring] Integrate phpbb with wordpress
By starme in forum Completed TransactionsReplies: 6Last Post: 23rd Feb 2011, 03:24 PM -
How to add TimThumb in WordPress?
By Palooo 2009 in forum WordpressReplies: 0Last Post: 12th Jan 2011, 04:40 PM -
[Hiring] Integrate Wordpress Blog
By Czechi in forum Completed TransactionsReplies: 1Last Post: 21st Jul 2010, 07:20 PM
themaLeecher - leech and manage...
Version 4.94 released. Open older version (or...