Photon
-
Photon works for images inside post content, but doesn’t for Thumbails on home page (front page).
this is how my function.php or index.php.
what should I change this?Theme Functions (functions.php)
} if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9 add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 50, 50, true ); // Normal post thumbnails add_image_size( 'single-post-thumbnail', 400, 9999 ); // Permalink thumbnail size } // retreives image from the post function getImage($num) { global $more; $more = 1; $content = get_the_content(); $count = substr_count($content, '<img'); $start = 0; for($i=1;$i<=$count;$i++) { $imgBeg = strpos($content, '<img', $start); $post = substr($content, $imgBeg); $imgEnd = strpos($post, '>'); $postOutput = substr($post, 0, $imgEnd+1); $image[$i] = $postOutput; $start=$imgEnd+1; $cleanF = strpos($image[$num],'src="')+5; $cleanB = strpos($image[$num],'"',$cleanF)-$cleanF; $imgThumb = substr($image[$num],$cleanF,$cleanB); } if(stristr($image[$num],'<img')) { echo $imgThumb; } $more = 0; } //retreive image endsMain Index Template (index.php)
<div class="thumb"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <?php //$thumb = thman_getcustomfield('thumb',get_the_ID()); if(!empty($thumb)) : ?> <?php $thumb_url = get_post_meta($post->ID , 'url_thumb', 'true' ); if($thumb_url!=""){ ?> <img src="<?php echo $thumb_url;?>" class="url_thumb" alt="<?php the_title_attribute(); ?>" /> <?php } else { ?> <img src="<?php getImage('1'); ?>"> <?php } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Photon’ is closed to new replies.