go41

Re: adding first image from post to front page spoiler :: Reply by Joern

von Joern am 28. Aug. 2010 | Keine Kommentare

looking at the code again I think you get the matches after preg_match so you could try this by putting "$image_src = …" below preg_match_all
The line with the comment ($image_src = “;) might help, try without this line first.

$the_content = $wpdb->get_var("SELECT post_content FROM $wpdb->posts WHERE ID = $id");
$home = get_option(‚home‘);
$pattern = ‚!<img.*?src="‘.$home.'(.*?)"!‘;
$image_src = “; // to clear any value if there is left from another query
preg_match_all($pattern, $the_content, $matches);?>
$image_src = $matches[‚1‘][0];
<?php if($image_src != “) …
is your pattern in the post really with the full path? I think timthumb prefers to get a path like

http: / / yoursite/wp-content/themes/arthemia/scripts/timthumb.php?src=/wp-content/images/…
without http after …ripts/timthumb.php?src=

So echo $image_src; before ..php if($image_src.. to check the value you give to timthumb

Last not least, tell us if you get something working…
____________________
you find me on Google+, Twitter and Facebook

(von: Joern)

Hier noch 4 weitere Ergebnisse dieses Threads:

adding first image from post to front page spoiler

12. Aug. 2010 (von: msderky)

hi so i have done some modification to my index.php. on the frontpage the code i am using is the index.php from your website, where you select one post from each category to be displayed on the frontpage. what i…

Re: adding first image from post to front page spoiler :: Reply by Joern

18. Aug. 2010 (von: Joern)

actually this code inside the else statement looks well, if there is showing even an image it's good.It should show the first image of the post you just display, to debug I sometimes just echo the values I set to…

Re: adding first image from post to front page spoiler :: Reply by msderky

28. Aug. 2010 (von: msderky)

hmm i reset the query but that didnt make a difference. when i echo the value of the id it was correct id with the post but when i echo the image_src it was not the right one for the…

Re: adding first image from post to front page spoiler :: Reply by msderky

10. Okt. 2010 (von: msderky)

hey! i've been away from the net for a while...moving to a different city! but thnx so much it worked after i moved the img src below the matches..thnk u thnk u thnk u! Weiterlesen →

Autor:

Du findest mich auch auf Google+, Twitter und Facebook!

Schreibe einen Kommentar

Pflichtfelder sind mit * markiert.


weitere forum Beiträge: