WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've spent hours trying to figure this out and its driving me mad. I'm not great with php code so I'm not sure if I'm doing this the best way anyway...

It should be simple - I have built a custom theme, and all I want to do is display a thumbnail that links to a lightbox effect once clicked.

I want my dimensions to be 214 width x unlimited height for the thumbnail, and 500 width x unlimited height for the lightbox effect. No cropping.

What I get from the code I currently have is a cropped thumbnail at 214 x 214 and cropped lightbox at 500 x 500.

Why is it cropping? I have checked the media settings within my wordpress admin and this makes no difference - assuming my code is overwriting these settings anyway (?)

In my function I am using the following code:

add_action( 'wp_enqueue_scripts', 'brian_scripts' );
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 214, 9999, false );
add_image_size('large', 500, 9999, true); //custom size

And to display them I'm using:

/*Template Name: Archive Canvases*/

<?php get_header('archivecanvas'); query_posts('cat=4&order=ASC'); ?>

<div class="header archivecanvasheader">
<h1><?php the_title(); ?></h1>
<div class="mainContent"><?php if (have_posts()) { ?>
<?php while (have_posts()) : the_post(); ?>

<div id="archiveContainer">
<div id="archivePic">

<a rel="lightbox" href="<?php $image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'large', true);
echo $image_url[0]; ?>"><?php if ( has_post_thumbnail() ) {


<div id="archivecanvasContent">
<h2><?php the_title(); ?></h2>
<div class="date"><?php the_time('Y') ?></div>
<p><?php the_excerpt(); ?></p>

<?php endwhile; ?>

<?php } ?>
<?php posts_nav_link(); ?></div>

<?php get_footer(); ?>`

Can anyone help or have any ideas if something else is overriding this? It might also be worth pointing out I have used the plugin Regenerate Thumbnails to resize the images I'm pulling through, but these haven't cropped them when I view them in my Media.

share|improve this question
add_action( 'wp_enqueue_scripts', 'brian_scripts' );
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 214, 9999, false );
add_image_size('large', 500, 9999, true); //custom size

This code is in your functions.php?

The docs for add_theme_support() suggest to only use it in the functions.php of the theme or attach it to the after_setup_theme hook.

Also you'll need to trigger the resizing of the images every time you change something to your code.

share|improve this answer
Yes the above code is in my functions.php. Is that code wrong? – user27907 Feb 23 '13 at 12:55
I'm not quite sure what I need to add to make it work properly. – user27907 Feb 23 '13 at 12:55
Ok. The code looks right for me in the first place. Can you just put an exit() into if ( function_exists( 'add_theme_support' ) ) { to see if it stops there? Also you could try to upload a new image and see if this is resized in the right way, if you are sure that the code in your functions.php is executed. – s1lv3r Feb 23 '13 at 13:12
I completely removed the code from the function and the thumbnails still displayed in the same cropped way. I deactivated Regenerate Thumbmails plugin and that made no difference, and checked my images arn't pre-cropped. I also played around with the image sizes within Media Settings..but nothing. It appears its getting the size setting from somewhere but where I really don't know.Would <?php get_header('archivecanvas'); query_posts('cat=4&order=ASC'); ?> have anything to do with it? I'm clutching at straws now. – user27907 Feb 24 '13 at 20:04
Also If I change the width on set_post_thumbnail_size( 214, 9999, false ); it does change the size of the image but in proportion and still cropped. However if I remove that line completely it still displays the original size (214 pixels). I my media settings again and its not getting that size from there - so I don't understand where its getting its sizing from. – user27907 Feb 24 '13 at 20:23

I suggest you should try this plugin and it will show you all image sizes added on your site by a plugin, theme or wordpress itself, it will surely help you trace the culprit size and you can simple delete it with this plugin or create your new size name it (set crop if you like) and then regenerate all thumbnails (use plugin for thumbnail regeneration off-course) and use it in your theme, hope it helps you and anybody else having same issue.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.