This simple patch adds support for selecting the original image size

in img_assist.module,v 1.56.2.6, line 772 add:

    // add a choice for 'original' if it's under the maximum size
    if (($properties_size['width'] <= $max_size[0]) && ($properties_size['height'] <= $max_size[1])) {
      $derivatives[$properties_size['width'] . 'x' . $properties_size['height']] = t('original');
    }

This possibly needs to also check if a user is allowed to set 'custom' sizes, but I figured that the original size (provided it's less than the max) is safe.

Comments

RobRoy’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new757 bytes

Here is a proper patch. I've tested it and it works great. This really helps with a TinyMCE bug when the image you're uploading is smaller than the 'preview' size, it will still show up in TinyMCE as super big when it is really smaller. Good stuff gregmac.

RobRoy’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.08 KB

Spoke too soon. I just noticed when uploading a big image, clicking the original setting results in a preview sized image. Looks like I fixed it, but will wait for reviews.

adrianmak’s picture

I used RobRoy patch and still got problem.
When I upload image e.g. 4.jpg thru img_assist, it will create 4 files
4.img_assist_properties.jpg
4.jpg
4.preview.jpg
4.thumbnail.jpg

Then I select original size and insert into my page node, the inserted code shown me that

<span class="inline left"><img src="http://192.168.103.190/avbuzz/sites/192.168.103.190.avbuzz/files/images/4.img_assist_custom.jpg" alt="4.jpg" title="4.jpg" class="image img_assist_custom" height="116" width="200"><span class="caption" style="width: 198px;"><strong>4.jpg</strong></span></span>

Why the size is 116x 200 and it's not the image original size ? ( After inserted the image, it will create a image called 4.img_assist_custom.jpg)

RobRoy’s picture

Did you use the last patch I posted? And do anonymous users have the 'view original images' permission enabled?

hyperlogos’s picture

Here's how I fixed this

--- 725,731 ----
      $node->title = str_replace("\n", ' ', trim($node->title));
      $node->body = str_replace("\r", ' ', strip_tags($node->body));
      $node->body = str_replace("\n", ' ', trim($node->body));
+     $image_info = image_get_info(file_create_path($node->images['_original']));

and

--- 770,782 ----
        }
      }

+     // Add a choice for 'original' if it's within the maximum size.
+     if ($img_assist_create_derivatives['custom_advanced'] && user_access('use original size')) {
+       if ($image_info['width'] <= $max_size[0] && $image_info['height'] <= $max_size[1]) {
+         $derivatives[$image_info['width']  .'x' . $image_info['height']] = t('original');
+       }
+     }
+

That pretty much covers it. Note that my patch also provides an additional permission to allow the use of the original size, and includes two new alignment options: center, and none. (I'm trying to roll all the functionality I want added into a single, working patch - but honestly they could be separate, it just complicates the context diffs because you need more context.

darren oh’s picture

Status: Needs review » Closed (duplicate)

Duplicate of issue 89076.