Could it be possible that the original image is also saved?

For example, my users crop an image to be displayed on the front page (I need cropped image because of the specific layout), but I would like that uncropped (regular) version of that image could be displayed on the node page without the need for users to upload the image once again.

CommentFileSizeAuthor
#26 formatter.patch1.6 KBchrisirhc
#26 formatterfile.patch1.26 KBchrisirhc
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nevets’s picture

You might be better off using the image field and image cache. That way the original image is saved and you can provide an image cache preset that provides a cropped image.

point-1’s picture

I can't do custom crop using imagecache. I am using imagefield + imagecache for other purposes, but in this case users must be able to choose the part of the image to crop.

yhager’s picture

Status: Active » Postponed

The only solution for this for the moment is to use two fields - one for the original image, another for the cropped one.
I'll keep this note for future revisions of this module.

Florian R’s picture

This would be realy cool feature. This way it wiuld also be possible to change the croped image.

mrfelton’s picture

you can do this with the imagecrop module.

yhager’s picture

Title: saving original image » saving and displaying original image
Assigned: Unassigned » yhager

While working on the 6.x version, it seems that this can be done (currently I am able to save the original for recropping). I might add an option to display it as well.

yhager’s picture

Title: saving and displaying original image » Add an option to display the original image
Version: 5.x-1.0 » 6.x-1.x-dev
Status: Postponed » Active

The original is saved in the 6.x version. This issue is left for tracking the other part - displaying it.

bflora’s picture

How about for D5?

yhager’s picture

@bflora: sorry, no plans to backport this into D5.

bflora’s picture

Ouch. That stinks. *bangs head against wall*

I'm sure the people behind it had great reasons, but why'd they make six so different from five that people like you aren't able to carve out enough time to backport your modules?

Ugh.

yhager’s picture

@bflora: imagefield undergone a major change between 5.x and 6.x. It was actually re-written twice(!). The result is very well done, and the code is very well crafted, so I was able to achieve this quite easily.
With D5, the situation was more complex, and it was difficult enough for me to achieve cleanly, so I gave up on this. With Drupal 5.x being in maintenance mode, I have put imagefield in maintenance mode too.

If you (or anyone) have the ability to help this in some way (donate code/money) - I would happily accept.

bflora’s picture

I understand where you're coming from. I didn't mean to come off badly.

I was more frustrated with why d5's core is so different form d6 that backporting modules and features is such a hassle.

I've got Zero dollars these days so no can do on the funding front. Perhaps someone else can step in and make it happen though.

tjodolv’s picture

Subscribing

Being able to choose between the cropped or the original – and any imagecache preset for both of these – will make this module *the* "killer-app" in my book :)

ScarabMonkey’s picture

seconded! I want to use the cropped image and when clicked I get a lightbox with the uncropped...

yhager’s picture

This shouldn't be very hard to accomplish, since we already save the original image, we just need to add a formatter that displays it.

My only problem on this is severe lack of time to handle this. If anybody can help with a patch, it would be a great help. Thank you all!

ShermanB’s picture

I just wanted to throw my two (virtual) cents in here and say that this would be an exceptional feature: Being able to custom crop to an imagecache, and drop the original in another one. Wow!!!

I'll be digging through the source to find a hack but look forward to seeing this in the future! Thanks for the great module!

bflora’s picture

Would still like to see this for D5. What would it cost to pay someone to get this working for D5?

matkeane’s picture

Hi,

I agree, it would be good to see a formatter solution, so that the full-sized image could be displayed through the UI. In the meantime, I've found a theme-based solution for a D6 site (might also work in D5 - not sure).

The original, uncropped, image is stored alongside the cropped version with the '.crop_display.jpg' suffix. Imagefield Crop loads a bunch of data about the cropped image into the node object, so on the full-page display, I've added a bit of code to my template for this particular node-type which uses imagecache to display a scaled version of the uncropped original.

$filepath = $node->field_banner_crop[0]['filepath']; // file path of cropped image
$filepath .= '.crop_display.jpg'; // add suffix for original
$img_alt = check_plain($node->title); // set image alt attr
$img_title = check_plain($node->title .', '. $node->field_banner_crop[0]['data']['description']); // set image title attr
$img = theme('imagecache', 'ukart_full', $filepath, $img_alt, $img_title); // get imagecache image tag
print $img;

I've just thrown this together quickly, so I need to add in some checks to make sure things are actually returning what they should be before I display the image, but it means I can show a cropped banner image in the teaser, which will link to a page with the original image and the title/description, which was what I needed.

bflora’s picture

Can you give me an example of what these URLs would look like? I played around with it a bit but don't think it works that way for D5 as I just got 404 for every different permutation I tried.

matkeane’s picture

I didn't mean to drag this issue too far away from the original request about the D6 UI...

but in my content-type, the imagefield_crop field path options are set to save images in 'images/banners', and when I look there I see:
/files/images/banners/IMG_2147.jpg (cropped image)
/files/images/banners/IMG_2147.jpg.crop_display.jpg (original uncropped image used for the crop interface)

Like I say, this is in D6, and things may be very different in the D5 version. Hope it helps anyway...

[Edit] Question to the module maintainer: My theme-based hack assumes that uncropped images will always be stored in the same way - is that a fairly safe assumption to make?

yhager’s picture

> Question to the module maintainer: My theme-based hack assumes that uncropped images will always be stored in the same way - is that a fairly safe assumption to make?

Sorry, I didn't notice the question, since you edited your reply.
I guess you can assume this will not change for the near future. Although the naming might not be idea (crop_display?? what was I thinking?), it is too dispressed now to change..

matkeane’s picture

Hi,

Thanks for confirming that. Would it be difficult, or a pain, to add an element to the node object with the filepath to the original image - e.g. $node->field_banner_crop[0]['filepath_original'] ? That way, it wouldn't matter if you did change the naming convention in the future, as each image would store the path to the original - although I guess that might mean another field stored in the database somewhere. Anyway, as things are, it works - thanks!

yhager’s picture

I prefer to add a display option that would be accessible through the UI, rather contaminating the node structure with a variable that very few developers will use.

matkeane’s picture

I agree that a UI option for that would be useful to more people, as this thread shows.

The word 'contaminate' seems a little harsh though! Extra little bits of information like that can be very useful to themers, and it's frustrating to have to make extra function calls - or worse still, database queries - to get data that could have been supplied by the module. But that's a general grumble - I'm not pointing a finger at your module when I say that!

daemon’s picture

This is the feature I am looking for!

Upload
1. Upload a large image
2. Select which part to scale/crop

Display
1. Node Preview displays scaled/cropped image
2. Full Node displays scaled/cropped image
3. Clicking on the image links to the original full sized one (or preferably, lightboxed original full sized image)

chrisirhc’s picture

Status: Active » Needs review
FileSize
1.26 KB
1.6 KB

I've added formatter for the field under the imagefield_crop module.

I don't know if there's a way to restrict it to fields using this particular widget, I left it for filefield and added a description indicating that it would only work for image fields that were used with the imagefield_crop widget.

yhager’s picture

Status: Needs review » Needs work

@chrisirhc: thank you for this!

I too haven't found a way to restrict the formatter according to the widget. For this reason, we need to handle the case that these formatters are used (mistakenly) by regular images(files?).

chrisirhc’s picture

No problem :)
Maybe add a check for the existence of the uncropped file? Link to or show the original if not found. Though I think it's probably bad practise for the theme function to do so much.. Not too sure.

cels’s picture

subscribe

I check the patchs on my drupal

drupalina’s picture

For example, I want to create a gallery with multiple Imagefields. I want the gallery to display thumbnails 100x100, which are created by Imagefield_Crop. But when people click on that thumb I want a 650x650 version of that picture to open up in Lightbox. (Problem: right now when they click the thumb it opens up a large version of the thumbnail, which looks all pixated and ugly)

And the best way to achieve this would be to integrate with Imagecache, so that the manual ImagefieldCrop could be added as an ImageCache action in one of the presets. In that way you actually end up killing 3 birds with one stone:
1) You can generate a manual thumbnail with ImagefieldCrop, and if there was no manual thumbnail then the system can fall back onto an automatic Scale-n-Crop by ImageCache module.
2) Importantly, users can go and edit the display of their Imagefields and tell drupal to display "Lightbox: ImagefiledCrop100x100 -> 650x650"
3) Users can have best of both worlds: thumbnails with manual Imagefield_Crop and larger versions with Imagecache.

I think http://drupal.org/project/imagecrop already integrated with ImageCache (even though this module is way more user-friendly for end-users). So maybe the efforts may could be combined, or maybe some of their Imagecache integration code can be taken.

I think making ImagefieldCrop work with Lightbox would be an essential addition here, because many people would want to turn to ImagefiledCrop module in case they are not happy with automatic thumbnails generated by Imagecache.

PS: I'm wondering if any of these patches are doing this (sorry, I don't know how to apply patches) and whether anything like this will be committed to .dev anytime soon. Once it's in .dev, I'll be the first one to test it.

jacktonkin’s picture

@drupalina: there is a patch in #426892: Add uncropped image to Display Fields list (imagecache) that does at least what you describe in #30.3.

bleen’s picture

superscribe

q0rban’s picture

Status: Needs work » Closed (duplicate)
q0rban’s picture

Status: Closed (duplicate) » Needs work

Well, maybe not as this issue isn't about imagecache is it? The two separate issues should probably be combined into one patch though, IMO.

robby.smith’s picture

subscribing

shiva7663’s picture

subscribing

sholn’s picture

It would be great having it also in views field !

marvix’s picture

subscribing

timezero’s picture

aidanlis’s picture

#26 works for me ... it would be nice if the module author gave these issues some direction. This issue was opened 3 years ago.

brunorios1’s picture

subscribing

crashtest_’s picture

Subscribe

vikramy’s picture

Subscribing

HansKuiters’s picture

#26 works for my use case. Thanks.

dahousecat’s picture

This worked for me:

function misc_node_load($nodes, $types) {
	
	foreach($nodes as $nid => $node) {
		
		/* If node has image check if it is a thumbnail and add the original */
		if(isset($node->field_image_n_thumb['und'][0])) {			
			$fullsize_fid = db_query("SELECT fid FROM file_managed 
				WHERE filename = CONCAT(
				(
					SELECT SUBSTR(filename, 1, LENGTH(filename)-4)
					FROM file_managed
					WHERE fid = :fid
				), '_0.jpg')", array(':fid'=>$node->field_image_n_thumb['und'][0]['fid']))->fetchField();
			
			if($fullsize_fid) {
				$node->field_image_n_thumb_fullsize['und'][0] = (array) file_load($fullsize_fid);
				$node->field_image_n_thumb_fullsize['und'][0]['alt'] = $node->field_image_n_thumb['und'][0]['alt'];
				$node->field_image_n_thumb_fullsize['und'][0]['title'] = $node->field_image_n_thumb['und'][0]['title'];
			}
		}
	}
	
}

Where field_image_n_thumb is the name of my cropped image field.

Not sure if this is the best solution but will certainly do for now...

ShaneOnABike’s picture

Status: Needs work » Reviewed & tested by the community

I don't see any reason why we can't push #26 patch ... I think it could be expanded to add more functionality but for now it's fine!

  • ram4nd committed 341ffb8 on 6.x-1.x authored by chrisirhc
    Issue #240849 by chrisirhc: Add an option to display the original image
    
ram4nd’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.