I'm displaying a group of thumbnails on a Wordpress site using the Magic Fields plugin

Here's the code in my template:

  $client_images = get_group ('images');
  foreach($client_images as $image){ ?>
  <div class="thumb">
      <a href="<?php echo $image['client_image'][2]['original']; ?>">
        <?php echo "<img src='".$image['client_image'][3]['thumb']."' />" ;?>
     <div class="tooltip">
      <p><?php echo $image['client_image_credit'][4]; ?></p>
      <p><?php echo $image['client_image_description'][5]; ?></p>
    <?php }

Where it says [ORIGINAL RESOLUTION], I'd like to print the resolution (e.g. "1200x800") of the source image.

Magic Fields uses phpThumb to generate thumbnails. phpThumb seems to have a function for this purpose:

//Getting the original size of the image
if( preg_match('/'.MF_FILES_NAME.'/',$image_name_clean) ){
  $image_name_clean = preg_replace('/'.MF_FILES_NAME.'\//','',$image_name_clean);
  $file = MF_FILES_DIR.$image_name_clean;
  $file = WP_CONTENT_DIR.DS.$image_name_clean;

if(file_exists($file) && (empty($_GET['w']) || empty($_GET['h']))){
    $size = @getimagesize($file);
    $default['w'] = $size[0];
    $default['h'] = $size[1];

Would anyone be able to help me connect the dots? Thanks!

1 Answer 1


I have worked many times with timthumb, but I do not know magic fields, and I am sorry, but i fail to understand a few things :

  1. you want to put a FULL resolution inside a tooltip ?
  2. does thispart of your code $image['client_image'][2]['original']; from above works ?
  3. if it does, there is no reason it should not work in the other div .

anyhow , you can pass parameters to timthumb directly for example like so :

define the variable with a URL

$thumb_for_tim = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ) ; // or in your case - your custom field value - if it returns a URL

and then call it

<img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo $thumb_for_tim; ?>&amp;h=155&amp;w=180&amp;zc=1&amp;f=2" alt="<?php the_title(); ?>" h & w are the height and width ..

EDIT ok, after your comment it is more clear . at first when you wrote "[ORIGINAL RESOLUTION]" I thought you wanted the image itself. in that case the answer is much simpler . PHP has a special function for that .


$size = getimagesize($filename);

so just point the URL of the image to $filename;

FYI - wordpress itself has a function to get imagesize , it is called


use like so :

$image_attributes = wp_get_attachment_image_src( $attachment->ID,full ); 

it will returns an array

  • [0] => url

  • 1 => width

  • [2] => height

    so echo $image_attributes[1]; will give you width, and $image_attributes[2] will give you height...

  • I'm not trying to display the image inside the tooltip, but rather the dimensions of the image. The thumbnail links to the full sized image, and the tooltip tells the user what the resolution of that image is, e.g., "1200px x 800px"
    – Ben L
    Dec 6, 2011 at 21:37
  • see my modified answer .
    – krembo99
    Dec 7, 2011 at 2:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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