Closed (won't fix)
Project:
ImageField
Version:
5.x-2.1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
29 May 2008 at 14:02 UTC
Updated:
10 Mar 2009 at 00:03 UTC
Phoenix enters the red planet, and Imagefield gets sortable images!
This patch adds a form field to each uploaded image that allows users to sort images by weight.
Do I have to say more, other than awesome!
?
Since this is a result of a joint work, please credit also smk-ka when committing this.
| Comment | File | Size | Author |
|---|---|---|---|
| imagefield-DRUPAL-5--2.sort_.patch | 3.79 KB | sun |
Comments
Comment #1
sunActually, this patch is against DRUPAL-5--2.
Drag'n'drop sorting via jQuery UI is a separate patch: #264171: Use jQuery UI for drag'n'drop sorting of images
Comment #2
dopry commentedWhy not do the weight sort in hook_field just before the deltas are compressed?
Comment #3
sunGood catch. However, we need to re-sort already existing images upon uploading a new one. Otherwise, a user may alter the weights of existing images, upload a new image, and find previously defined weights reset.
Comment #4
dopry commentedseems like as along as the weight is set on a new upload the ordering will happen in form table properly. We only need to save this data in hook_field.. you do know hook_field is called from within nodeapi....
The only reason you should be using nodeapi instead of hook_field with field data is to circumvent the order in which hooks are called naturally by content.module re: content default implementations and field implementations. This is not a case in which you need to shortcut that behavior.
.darrel.
Comment #5
canen commentedSub.
Comment #6
drasgardian commentedI agree. "awesome!". Well done and thanks.
Comment #7
solutiondrop commentedI just tried this patch and it works for up to 11 images. The first image is assigned a weight of 0 and the next image is assigned a 1, etc. When you reach the 12th upload the weight is assigned as -10 and then the 13th image is also assigned a -10. Is there a way to allow the weight to go beyond 10?
Thanks!
Comment #8
muhleder commentedCouple of pages on increasing the weight limit beyond the default of 10 here
http://drupal.org/node/117274
http://drupal.org/node/68823
Would be nice to work out how do this in this patch just for the imagefield module.
Comment #9
onelittleant commentedIf you want to handle more than 10 images, you can add a '#delta' attribute to the weight form element. There's a section of this patch that looks like this:
make it look like this (for 100 images):
apologies... not a patch master...
THANK YOU ALL! I've been looking for this for a while.
Comment #10
socialnicheguru commentedYOU GUYS AND GALS ARE SOOOOO FLIPPING AWESOME! (ok enough with the caps). This is really really really really great. it makes things very easy.
Comment #11
momper commentedgreat - thanks a lot ...
Comment #12
sansui commentedYou are awesome, I just wanted you to know that. This was perfect for our Ubercart installs - it wasn't so hot being unable to change the main image! This is simple, but perfect - thanks again so much!
Comment #13
camb416 commented@onelittleant
I tried exactly as you said, but got this error message...
Any advice would be very much appreciated...
Comment #14
ricardo37 commentedI got the same result as camb416. I fixed the problem by removing the extra line of patch code recommended to allow sorting for >10 images. I added that line manually to the imagefield.module file once the patch was successfully completed using the original patch file.
Comment #15
aterchin commentedsubscribe
Comment #16
quicksketchTime to move on to Drupal 6. I'm marking this won't fix as it's built into Drupal 6 and likely to break ImageField in some way or another.