the_
the_

Reputation: 1173

Original Size Thumbnail Issue

I have a Wordpress site that has a jQuery slider. I have custom post type called Slides that uses the title for the heading title for the slide, and the featured image as the slide background. Here's my code:

<?php
  $args = array(
    'post_type' => 'slide'
  );
  $loop = new WP_Query($args);

  $z = 0;

  while($loop->have_posts()): $loop->the_post();
     $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID, 'full' ) );
  ?>

    <div class="item <?php if ($z == 0){ echo "active";}?>">
      <img src='<?= $thumbnail_src[0]?>'>
      <div class="container">
        <div class="carousel-caption">
          <h1><?php the_title(); ?></h1>
          <p><?php the_content(); ?></p>
        </div>
      </div>
    </div>

<?php
  $z++;
  endwhile;
?>

The problem is that everytime a site admin puts in a featured image, the image url gets set to:

http://example.com/wp-content/uploads/2014/01/image-150x150.png

instead of what it should be:

http://example.com/wp-content/uploads/2014/01/image.png

How do I change this? Thanks for all help!

Upvotes: 0

Views: 71

Answers (1)

Rahil Wazir
Rahil Wazir

Reputation: 10132

Your code is fine just a little change

Replace this code

$thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID, 'full' ) );

With this:

$thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID), 'full' );

You are passing second parameter to get_post_thumbnail_id() instead of wp_get_attachment_image_src()

Better read docs

Upvotes: 4

Related Questions