WordPress.org

Ready to get started?Download WordPress

Forums

Trying to retrieve all original uploaded image files for a post. (1 post)

  1. supergab
    Member
    Posted 2 years ago #

    Hello,

    I've uploaded the all the images to my posts and cropped them using the "Apply changed to: All image sizes" option in order to have 1x1 ratio for multiples image sizes I set up with add_image_size in functions.php.

    Now the problem I'm facing is that when I'm trying to retrieve the 'full' original uploaded files within the loop with the initial proportions, I always end up with squared images. But I can see that the original uploaded files are still there in the uploads folder (in the FTP).

    I use the following code in functions.php:

    <?php
    function my_attachment_all_images($postid=0, $size='full', $attributes='') {
        if ($postid<1) $postid = get_the_ID();
        if ($images = get_children(array(
            'post_parent' => $postid,
            'post_type' => 'attachment',
            'numberposts' => -1,
            'orderby' => 'menu_order',
            'post_mime_type' => 'image',)))
            foreach($images as $image) {
                $attachment=wp_get_attachment_image_src($image->ID, $size);
                ?><img src="<?php echo $attachment[0]; ?>" alt="" class="imarge" /><?php
            }
    }?>

    But using 'full' for the size give me a cropped file not the original uploaded file with initial proportions. The output is:

    myImageFile-e1343105908459.jpg (cropped 1x1)

    instead of

    myImageFile.jpg (original 3x2)

    Many thanks for your time and help.

Topic Closed

This topic has been closed to new replies.

About this Topic