logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$5
Update this script so all images use tim thumb

I have this script which currently just makes images form an external link use tim thumb, i want all images to use timthumb if possible (or happy to take other suggestions that will show a resized image without actually having to go and manually resize it).

Here's the script


<?php
if ( has_post_thumbnail() ) {
echo '<div class="post_wp_thumb" >';
the_post_thumbnail('single-post-thumbnail');
echo '</div>';
} else {
echo '<div class="post_wp_thumb_comm" style="border: 1px solid #EFEFEF;text-align: center;">';
$image_link = get_first_image();
$permalink = get_permalink($post->ID);
if ($image_link != "external"){
echo '<a href="'. $permalink .'"> <img src="http://images.dropdeadgorgeousdaily.com/wp-content/themes/thesis_18/custom/scripts/timthumb.php?src='. $image_link .'&h=100&w=100&zc=1" alt="online shopping" title="online shopping" height="100" width="100"> </a>';
} else {
echo '<a href="'. $permalink .'"> <img src="'. get_first_image_2() .'" height="100" width="100" alt="Shop it!" title="online fashion"> </a>';

}

echo '</div>';

}


?>

This question has been answered.

kateM82 | 01/24/12 at 6:08am Edit


(4) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    01/24/12
    6:18am
    Andrew Wong says:

    You already have TimThumb for the feature image, only the default image doesn't use TimThumb. Check how $image_link URL looks like and you should be fine with the TimThumb for the default image...?

  • avatar
    Last edited:
    01/24/12
    6:18am
    Arnav Joy says:

    try this


    <?php

    if ( has_post_thumbnail() ) {

    $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');


    echo '<div class="post_wp_thumb" >';

    echo '<a href="'. $permalink .'"> <img src="http://images.dropdeadgorgeousdaily.com/wp-content/themes/thesis_18/custom/scripts/timthumb.php?src='. $large_image_url[0] .'&h=100&w=100&zc=1" alt="Shop it!" title="online fashion"> </a>';

    echo '</div>';

    } else {

    echo '<div class="post_wp_thumb_comm" style="border: 1px solid #EFEFEF;text-align: center;">';

    $image_link = get_first_image();

    $permalink = get_permalink($post->ID);

    if ($image_link != "external"){

    echo '<a href="'. $permalink .'"> <img src="http://images.dropdeadgorgeousdaily.com/wp-content/themes/thesis_18/custom/scripts/timthumb.php?src='. $image_link .'&h=100&w=100&zc=1" alt="online shopping" title="online shopping" height="100" width="100"> </a>';

    } else {

    echo '<a href="'. $permalink .'"> <img src="http://images.dropdeadgorgeousdaily.com/wp-content/themes/thesis_18/custom/scripts/timthumb.php?src='. get_first_image_2() .'&h=100&w=100&zc=1" alt="Shop it!" title="online fashion"> </a>';



    }



    echo '</div>';



    }





    ?>

    • 01/24/12 6:21am

      kateM82 says:

      Worked like a charm, thanks!

    • 01/24/12 6:22am

      Arnav Joy says:

      or try this

      if ( has_post_thumbnail() ) {

      $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'single-post-thumbnail');


      echo '<div class="post_wp_thumb" >';

      echo '<a href="'. $permalink .'"> <img src="http://images.dropdeadgorgeousdaily.com/wp-content/themes/thesis_18/custom/scripts/timthumb.php?src='. $large_image_url[0] .'&h=100&w=100&zc=1" alt="Shop it!" title="online fashion"> </a>';

      echo '</div>';

      } else {

      echo '<div class="post_wp_thumb_comm" style="border: 1px solid #EFEFEF;text-align: center;">';

      $image_link = get_first_image();

      $permalink = get_permalink($post->ID);

      if ($image_link != "external"){

      echo '<a href="'. $permalink .'"> <img src="http://images.dropdeadgorgeousdaily.com/wp-content/themes/thesis_18/custom/scripts/timthumb.php?src='. $image_link .'&h=100&w=100&zc=1" alt="online shopping" title="online shopping" height="100" width="100"> </a>';

      } else {

      echo '<a href="'. $permalink .'"> <img src="http://images.dropdeadgorgeousdaily.com/wp-content/themes/thesis_18/custom/scripts/timthumb.php?src='. get_first_image_2() .'&h=100&w=100&zc=1" alt="Shop it!" title="online fashion"> </a>';



      }



      echo '</div>';



      }

    • 01/24/12 6:33am

      kateM82 says:

      Actually spoke to soon. Worked like a charm in one spot, tried to apply it within a php widget and I get this error

      Parse error: syntax error, unexpected '=', expecting ',' or ';' in /home/ddgd/public_html/wp-content/themes/thesis_18/custom/custom_functions.php(508) : eval()'d code on line 34

      Full code is here:



      <div class="just-added-comms-hp" style="float: left; width: 270px; ">

      <?php $temp_query = $wp_query; ?>
      <?php
      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
      $sticky=get_option('sticky_posts');
      $args=array(
      'caller_get_posts'=>1,
      'post_type' => 'dshop',
      'dshop-type' => 'favourite',
      'orderby'=> rand,
      'post__not_in' => $sticky,
      'paged'=>$paged,
      'posts_per_page'=>9,
      );
      //query_posts($args);
      $my_query = new WP_Query($args);

      while ($my_query->have_posts()) : $my_query->the_post();
      ?>
      <div class="swagshop_about" style="width:75px;margin-right: 9px; height: 75px; margin-bottom:10px;padding-right: 5px;">
      <?php
      if ( has_post_thumbnail() ) {
      echo '<div class="post_wp_thumb" >';
      the_post_thumbnail('single-post-thumbnail');
      echo '</div>';
      } else {
      echo '<div class="post_wp_thumb_comm" style="border: 1px solid #EFEFEF;text-align: center; width: 75px; height: 75px;">';
      $image_link = get_first_image();
      $permalink = get_permalink($post->ID);
      if ($image_link != "external"){
      echo '<a href="'. $permalink .'"> <img src="/wp-content/themes/thesis_18/custom/scripts/timthumb.php?src='. $image_link .'&h=70&w=70&zc=1" alt="online fashion" title="online shopping" width="70" height="70" style="width: 70px; height: 70px;"> </a>';
      } else {
      echo '<a href="'. $permalink .'"> <img src="http://images.dropdeadgorgeousdaily.com/wp-content/themes/thesis_18/custom/scripts/timthumb.php?src='. get_first_image_2() .'&h=70&w=70&zc=1" alt="Shop it!" title="online fashion" height="70" width="70"> </a>';
      }

      echo '</div>';

      }


      ?>

      </div>

      <div class="post-theme post" id="post-<?php the_ID(); ?>">
      <div class="clear"></div>
      </div>

      <!-- Post -->
      <?php endwhile; ?>
      <br class="clear" />

      <?php
      $wp_query = $temp_query;
      wp_reset_query();
      ?>


      </div>

    • 01/24/12 6:56am

      Arnav Joy says:

      can you paste here line no. 34 complete

  • avatar
    Last edited:
    01/24/12
    6:19am
    Romel Apuya says:

    have you tried something like this?

    <?php
    if ( has_post_thumbnail() ) {
    echo '<div class="post_wp_thumb" >';
    the_post_thumbnail('single-post-thumbnail');
    echo '</div>';
    } else {
    echo '<div class="post_wp_thumb_comm" style="border: 1px solid #EFEFEF;text-align: center;">';
    $image_link = get_first_image();
    $permalink = get_permalink($post->ID);
    if ($image_link != "external"){

    echo '<a href="'. $permalink .'"> <img src="http://images.dropdeadgorgeousdaily.com/wp-content/themes/thesis_18/custom/scripts/timthumb.php?src='. $image_link .'&h=100&w=100&zc=1" alt="online shopping" title="online shopping" height="100" width="100"> </a>';
    } else {
    echo '<a href="'. $permalink .'"> <img src="http://images.dropdeadgorgeousdaily.com/wp-content/themes/thesis_18/custom/scripts/timthumb.php?src='. get_first_image_2().'&h=100&w=100&zc=1" height="100" width="100" alt="Shop it!" title="online fashion"> </a>';
    }
    echo '</div>';
    }
    ?>


  • avatar
    Last edited:
    01/24/12
    6:28am
    Kannan C says:

    @Arnav Joy: Hey Dude, i respect your answers but why don't you use code wrap for your codes? It looks annoying. Please try to make use of code wrap.

This question has expired.



Gabriel Reguly, idt, Francisco Javier Carazo Gil voted on this question.



Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.