Support » Plugin: Pods - Custom Content Types and Fields » Calling specific image size

  • Resolved Olly – OWMC


    Hello, i am using this code to call a list of pod items each with image fields:

    $services = new Pod('services');
    $services->findRecords('id ASC', -1);
    $total_services = $services->getTotalRows();
    <?php if( $total_services>0 ) : ?>
    <?php while ( $services->fetchRecord() ) : ?>
    $services_id        = $services->get_field('id');
    $services_name      = $services->get_field('name');
    $services_photo     = $services->get_field('main_photo');
    $services_desc     = $services->get_field('description');
    $services_slug      = $services->get_field('permalink');
    $services_photo     = $services_photo[0]['guid'];
    <div class="menubox2" style="background:url('<?php echo $services_photo; ?>')center;">

    Which works great. Until my client started uploading 3-4000px width images.

    So I wanted to know how I could make sure it only calls a specific size (thumb/medium/large/original).

Viewing 5 replies - 1 through 5 (of 5 total)
  • This might be helpful:

    I’m unsure if your services is an extension of post, but I see that you have an ID, You could use the ID and then specify the size of the image that gets displayed with the second parameter of wp_get_attachment_image_src.

    Hope this helps!
    If not, then I hope you find a solution soon!

    thanks Mork, not sure how i can integrate wp_get_attachment_image into my code above. $services_photo is defined by the pod item field “main_photo”.

    wordpress by default creates different sizes of all uploaded images and i wanted to take advantage of that. also have used smushit but don’t think this is working either.

    l for now i’m just going to tell the client to upload smaller images.

    Plugin Author Scott Kingsley Clark


    Any images uploaded through Pods will be automatically resized by WordPress. So all you need to do is pass the file’s ID into wp_get_attachment_image_src and that should work well.

    Or you can alternatively use our handy wrapper function and pass the file data, ID, or GUID into it:


    Thanks Scott, i will have to come back to this later in the week hopefully. Will update!

    By the way, new pods site looks slick! Waiting for the storm of work I have on to die down a bit before I get thoroughly into it.

    Olly – OWMC


    had a good chat with Phil Lewis.

    First off I’ve corrected my syntax so it is up to date. The syntax I originally posted here is out of date (

    In summary it now looks like this:

    $services = pods('services');
    $services->find('id ASC', -1);
    $total_services = $services->getTotalRows();
    <?php if( $total_services>0 ) : ?>
    <?php while ( $services->fetch() ) : ?>
    $services_id        = $services->field('id');
    $services_name      = $services->field('name');
    $services_photo     = $services->field('main_photo');
    $services_slug      = $services->field('permalink');
    $services_photo     = pods_image_url ( $services_photo, $size = 'medium', $default = 0, $force = false );

    Where “medium” could also be set to thumbnail, original, large…

    Basically I have learnt a bit about php. I was trying to implement pods_image_url but i was trying to use it as a “method”, like so:
    $album_photo = $album->pods_image_url ( $album_photo, $size = 'medium', $default = 0, $force = false );

    Whereas I should have been using it as a “global function”:
    $album_photo = pods_image_url ( $album_photo, $size = 'medium', $default = 0, $force = false );

    Ah the endorphins running around my brain…


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Calling specific image size’ is closed to new replies.