go41

Re: TimThumb Question :: Reply by Joern

von Joern am 22. Okt. 2011 | Keine Kommentare

I had some demo themes with timthumb on my demo site and was using the latest script in july ’11 (‚VERSION‘, ‚1.11‘).

In august I found .php files in the themes /cache folder, while there should be only images…

Sure, first thing I did was disabling all themes using timthumb.
Now to your question: Using a theme with different sizes of images I am going for post thumbnails handled now by WordPress.
There is a plugin http://wordpress.org/extend/plugins/reg … humbnails/ doing the creation of all image sizes for your images.
To set image size you can use the ‚Media Settings‘ in your dashboard and also functions.php in your theme.
First thing would be to enable post-thumbnails for your theme by adding two lines into your functions.php before the ‚?>‘

if ( function_exists( ‚add_theme_support‘ ) )
add_theme_support( ‚post-thumbnails‘ );
just below these two lines you also can set additional thumb sizes, looks like this in a theme I use:

if ( function_exists( ‚add_theme_support‘ ) )
add_theme_support( ‚post-thumbnails‘ );
set_post_thumbnail_size( 150, 150, true ); // 150 pixels wide by 150 pixels tall, hard crop mode for archive and index
add_image_size( ‚300sq-thumbnail‘, 300, 300, true ); // 300×300 big thumbnail size for headlnes
add_image_size( ’80sq-thumbnail‘, 80, 80, true ); // 80×80 small thumbnail size for index below
add_image_size( ‚100×65-thumbnail‘, 100, 65, true ); // 100×65 small thumbnail size for index below
Lets say you put this in your functions.php and run the plugin mentioned above, you will get all your images in your uploads folder in these sizes created additionally.
Now it’s time to change the code to call the image in your theme files.

Replace for example in index.php (150px square image)

<div class="spoiler">
<?php $values = get_post_custom_values("Image"); if (isset($values[0])) {
if(substr($values[0], 0, 3) == ‚wp-‚) { $values[0]= "/".$values[0];} // add slash if local url does not have to be compatible to arthemia ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
<img src="<?php echo bloginfo(‚template_url‘); ?>/scripts/timthumb.php?src=<?php $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=150&h=150&zc=1&q=80" alt="<?php the_title(); ?>" class="left" /></a>
<?php } ?>
<?php the_excerpt(); ?>
</div>
with:

<div class="spoiler">
<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_post_thumbnail(‚thumbnail‘, array(‚class‘ => ‚left‘ , ‚alt‘ => get_the_title() , ‚title‘ => get_the_title() )); //get the 150px square ?>
</a>
<?php } ?>
<?php the_excerpt(); ?>
</div>
and for the 80px square replace:

<div class="spoiler">
<?php $values = get_post_custom_values("Image"); if (isset($values[0])) {
if(substr($values[0], 0, 3) == ‚wp-‚) { $values[0]= "/".$values[0];} // add slash if local url does not have to be compatible to arthemia ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
<img src="<?php echo bloginfo(‚template_url‘); ?>/scripts/timthumb.php?src=<?php $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=80&h=80&zc=1&q=80" alt="<?php the_title(); ?>" class="left" /></a>
<?php } ?>
<p><?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,23) . " …rn"; ?></p>
</div>
with this post_thumb code:

<div class="spoiler">
<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_post_thumbnail(’80sq-thumbnail‘, array(‚class‘ => ‚left‘ , ‚alt‘ => get_the_title() , ‚title‘ => get_the_title() )); ?>
</a>
<?php } ?>
<p><?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,23) . " …rn"; ?></p>
</div>
Okay, that’s to start, either switch to a new theme using post thumbnails or modify arthemix, it’s some work to do…
Tell me what you will do, I can help more – but not tonight ;-)
____________________
you find me on Google+, Twitter and Facebook

(von: Joern)

Hier noch 1 weitere Ergebnisse dieses Threads:

TimThumb Question

22. Okt. 2011 (von: sdn001)

I saw the post about TimThumb exploits and the fact that you've removed all themes using TimThumb from your site based on that.I have a WordPress site I am building based on your arthemix-bronze theme, but I have put a…

Autor:

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

Schreibe einen Kommentar

Pflichtfelder sind mit * markiert.


weitere forum Beiträge: