0
Welcome Guest! Login
0 items Join Now

Thumbnail

    • Adrian's Avatar
    • Adrian
    • Newbie
    • Posts: 19
    • Thanks: 0

    Thumbnail

    Posted 11 years 10 months ago
    • Cliff Pfeifer's Avatar
    • Cliff Pfeifer
    • Preeminent Rocketeer
    • Posts: 8444
    • Thanks: 20
    • Website Developer

    Re: Thumbnail

    Posted 11 years 9 months ago
    • Hi, this feature is not part of Gantry. You can use the featured image and display that or a thumbnail using that, that is the only post image that is used in Gantry, as it's a Wordpress default. codex.wordpress.org/Post_Thumbnails

      If you need information about how to use the custom function you linked to, you'll have to contact the author, that is something he made, it's not part of our theme by default and we can't guarantee that it works.
    • The difficult we do immediately, the impossible takes a little longer.
    • Cliff Pfeifer's Avatar
    • Cliff Pfeifer
    • Preeminent Rocketeer
    • Posts: 8444
    • Thanks: 20
    • Website Developer

    Re: Thumbnail

    Posted 11 years 9 months ago
    • Hi, all the loops are in the theme directory -> html. Which one you use will depend on which type of page you're working with.
    • The difficult we do immediately, the impossible takes a little longer.
    • Adrian's Avatar
    • Adrian
    • Newbie
    • Posts: 19
    • Thanks: 0

    Re: Thumbnail

    Posted 11 years 9 months ago
    • Cliff Pfeifer's Avatar
    • Cliff Pfeifer
    • Preeminent Rocketeer
    • Posts: 8444
    • Thanks: 20
    • Website Developer

    Re: Thumbnail

    Posted 11 years 9 months ago
    • Hi, I think you're trying to make it too hard on yourself. The code you're looking at is primarily designed to change the size of the thumbnail image by using a timthumb script, which by the way, is one of the most hacked scripts on the internet - you shouldn't use that anyway. We've removed the timthumb script from all of our themes and plugins specifically for this reason.

      If you want to change the size of the thumbnails, there are easier ways that are built into Wordpress. See this link for details: codex.wordpress.org/Function_Reference/add_image_size
      Basically, the size changes will only happen for images that you upload after you add this code - any existing images will be the same - unless you re-upload them. You only need to worry about that if you need to change the size.

      If you're just trying to show the image - the loops in Gantry already have a call to get the featured image - all except page.php, search.php and single.php. And Even though they aren't in those loops, they can be easily added.
      <!-- Begin Thumbnail -->
                               
           <p>
           <?php if(function_exists('the_post_thumbnail') && has_post_thumbnail()) : the_post_thumbnail('gantryThumb', array('class' => 'rt-image '.$gantry->get('thumb-position'))); endif; ?>                         
           </p>
       
      <!-- End Thumbnail -->
      This code displays a thumbnail from the featured image inside the loop. The post thumbnail function already exists in the theme, so you could actually get away with using:
      <?php the_post_thumbnail('full'); ?>
      The 'full' means you're using the full size image, you can use thumb, medium, small ECT - as seen here: codex.wordpress.org/Function_Reference/t...mbnail#Default_Usage

      All of this is built into Wordpress already, you don't need complicated functions using external scripts and resize functions. It's better to use what Wordpress has and do a bit of planning on your image sizes before hand. If the post_thumbnail function is in your loop - it will show the featured image.
    • The difficult we do immediately, the impossible takes a little longer.
    • Adrian's Avatar
    • Adrian
    • Newbie
    • Posts: 19
    • Thanks: 0

    Re: Thumbnail

    Posted 11 years 9 months ago
    • Work!

      I added in functions.php
      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.png";
        }
        return $first_img;
      }

      in /html/index.php above the <?php the_excerpt(); ?>
      <div id="thumb"><a href="<?php the_permalink(); ?>"><img src="<?php echo catch_that_image() ?>"></a></div>

      in style1.css
      #thumb img{
      width:100px;
      height:100px;
      float:left;
      margin-right: 5px;
      ...}

      problem was that i added in index.php, not in html/index.php

      Cliff Pfeifer Thank you very very much for response, I almost quit.

Time to create page: 0.043 seconds