0

It is possible to use add_image_size in functions.php to get the original uploaded file size. Because when I uploaded the images to my posts I cropped them in order to have 1x1 ratio for all my image sizes and I remember using the All images option.

So now when I use full or large I always end up with squared images. But I can see that the original uploaded files with the good proportions are still there in the uploads folder and I would like to use retrieve them if possible, somehow.

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 the cropped file not the original uploaded file. The output is:

myImageFile-e1343105908459.jpg (cropped 1x1)

instead of

myImageFile.jpg (original 3x2)

Many thanks for your time and help.

1 Answer 1

1

You can always get the url for original attachment image. I don't see any code from you so i don't know which one is good for you but there are lots of functions on core which will get you the original image.

here are some

http://codex.wordpress.org/Function_Reference/wp_get_attachment_url

http://codex.wordpress.org/Function_Reference/the_post_thumbnail

http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src

When you scroll down bottom of the page you will see more related functions. So, searching on codex is always a good idea when you learning :)

1
  • Trying to use full doesn't work like I explained. It returns the cropped version.
    – Gab
    Commented Sep 21, 2012 at 2:44

Your Answer

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

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