• Resolved jcampbell88

    (@jcampbell88)


    Hello,

    I’m having a bit of trouble applying a different image size to property photos, the template file ‘property-images.php’ currently fetches images via:

    $image = wp_get_attachment_image( $gallery_attachment, 'original' );

    When I try and apply large/medium/thumbnail, etc. instead of original it still loads the full-size image. Client is in the habit of uploading enormous camera shots so I’d like to be able to load smaller versions if possible, could you possibly point me in the right direction?

    Many thanks,

    J

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Property Hive

    (@propertyhive)

    Hi J,

    You should be able to do exactly what you’ve said and change the line you reference, but replace ‘original’ accordingly. I’ve tried it here on a development site and it worked as expected.

    There must be something else at play. Maybe a caching plugin? File not being uploaded after making the change? etc.

    Steve

    Thread Starter jcampbell88

    (@jcampbell88)

    Would this only affect images uploaded after the change? All the images on the site have the necessary sizes generated.

    Will also see if anything is being cached.

    Thanks,

    J

    Plugin Author Property Hive

    (@propertyhive)

    “Would this only affect images uploaded after the change?”
    – No. Should kick right into effect.

    Steve

    Thread Starter jcampbell88

    (@jcampbell88)

    Regenerated all the thumbnails and disabled any caching plugins but the problem persists:

    https://test.blackhay.co.uk/property/troon-ka10/

    Here’s the full code from my property-images.php page:

    <?php
    /**
     * Single Property Images
     *
     * @author      PropertyHive
     * @package     PropertyHive/Templates
     * @version     1.0.0
     */
    
    if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
    
    global $post, $propertyhive, $property;
    
    $gallery_attachments = $property->get_gallery_attachment_ids();
    ?>
    <div class="images">
    
        <?php
            if ( !empty($gallery_attachments) ) {
    
                echo '<div class="slider-for slick-slide-img--full">';
    
                foreach ($gallery_attachments as $gallery_attachment)
                {
                    $image_title = esc_attr( get_the_title( $gallery_attachment ) );
                    $image_link  = wp_get_attachment_url( $gallery_attachment );
                    $image = wp_get_attachment_image( $gallery_attachment, 'large' );
    
                    echo '<div>' . apply_filters( 'propertyhive_single_property_image_html', sprintf( '<img src="%s" alt="Placeholder" />', $image_link, $image_title, $image ), $post->ID ) . '</div>';
                }
    
                echo '</div>';
    
            } else {
    
                echo apply_filters( 'propertyhive_single_property_image_html', sprintf( '<img src="%s" alt="Placeholder" />', ph_placeholder_img_src() ), $post->ID );
    
            }
        ?>
    
        <?php do_action( 'propertyhive_product_thumbnails' ); ?>
    
    </div>

    Thumbnail support is added via my theme’s functions file, if that matters.

    Plugin Author Property Hive

    (@propertyhive)

    In the link provided the original images uploaded are only 1000px wide to begin with so, even if you request large, your going to get the original.

    What happens if you change ‘large’ to ‘medium’ or ‘thumbnail’?

    Steve

    Thread Starter jcampbell88

    (@jcampbell88)

    Nothing happens – original image is still loaded, here’s one where the orig is 2000px:

    https://test.blackhay.co.uk/property/prestwick-ka9/

    I have large defined as max. 700px so even if it’s 1000 it should still be resized?

    Jonny

    Plugin Author Property Hive

    (@propertyhive)

    On that link I’m seeing the large version (i.e. 700px wide) being used now.

    Steve

    Thread Starter jcampbell88

    (@jcampbell88)

    Hi Steve,

    It was the apply_filters that was messing everything up, wasn’t calling the $image variable so the size wasn’t being applied.

    Thanks for your help.

    J

    Thread Starter jcampbell88

    (@jcampbell88)

    Marking as resolved.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Setting property image size’ is closed to new replies.