Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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 :)

share|improve this answer
    
I edited with more infos. Thanks –  Gab Jul 25 '12 at 21:17
    
Trying to use full doesn't work like I explained. It returns the cropped version. –  Gab Sep 21 '12 at 2:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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