Closed (fixed)
Project:
ImageField
Version:
5.x-2.0-rc6
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 Feb 2008 at 00:39 UTC
Updated:
2 Apr 2008 at 21:55 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jbrauer commentedThis is a result of
The workaround until a patch gets rolled (I'm working on one) is that multiple images has to be enabled and the limit has to be set above 0. Setting to 0 causes this to be false.
Comment #2
jbrauer commentedHere's a quick patch. I'm pretty sure this isn't the ideal way to handle it and it introduces a text bug for settings where multiple's aren't allowed but it's a place to work from.
Comment #3
jbrauer commentedComment #4
jbrauer commentedAnother patch that resolves the issue of text for situations where multiples are not allowed or they are and the max images is set to 1. The old "replace" text has been removed because we never get there. The only way to replace a single image now is to delete the existing image first.
Comment #5
sunhttp://drupal.org/node/225584 has been marked as duplicate of this issue.
Comment #6
a_c_m commentedsubscribing, great to see a patch for this rolled into a rc7 release.
Comment #7
jbrauer commentedThis doesn't handle the problem of not being able to see the uploaded image if there is a single image and because the edit form is missing it is not possible to delete the image.
Comment #8
jpetso commentedI might be wrong, but I think it's as simple as this patch. Works for me for single and multiple fields, tested with 0, 1 and 2 max allowed images. I think we should keep the "replace" code because it's better for usability - single-image fields should always replace the file instead of asking the user to manually delete it.
Comment #9
jpetso commentedArgh, wrong patch - missing the !$field['multiple'] condition that makes single-value fields work for all "max images" settings.
Comment #10
jpetso commentedOk, one more: the above patch had one condition too much, and removing that made it clear that there are too much negations in the if condition. Therefore, let's swap the if and else branches, and have a "positive" condition instead.
Comment #11
jbrauer commented+1 this is much better...
I did add back the handling for the special case where multiple is selected with a limit of 1 image so the text doesn't read "1 images" etc.
Comment #12
jpetso commentedThere's actually a function in Drupal that allows strings to be translated while respecting singular/plural differences (even those for languages with more than two plural forms): format_plural() is what we want to use here. Probably by making "1 image" a placeholder for the main string and thus keeping only one copy. I don't have the time to roll the patch right now, feel free to do it first :D
Comment #13
Anonymous (not verified) commentedjpesto's patch is working for me. Thanks! The bug really disrupted my project.
Comment #14
jpetso commentedI hate to nitpick, but it's jpetso. First the t, then the s.
(...ok, nitpicking actually doesn't feel so bad to me ;).
Comment #15
jbrauer commentedThanks jpetso! I'd spent too much time looking for that the other day but with the function got it.... here's a patch with it included.
Comment #16
jpetso commentedOk, this patch thing just didn't work as I wanted it to yesterday. Here's the patch that I had previously wanted to upload (but uploaded a copy of the one before that instead), plus incorporating format_plural as posted by JBrauer. I believe this patch is now what we want to apply.
@JBrauer: please generate your patches with the "-u" option, that makes nice readyble "unified" diffs with pluses and minuses.
Comment #17
sunActually, it's
cvs diff -up. See http://drupal.org/patch/create for detailed information about Drupal patch standards.Comment #18
jbrauer commentedThanks for the patch tip... I think this one is done correctly (with -up).
One change from patch #16 -
$max_images <= count($items)as the test instead of:
count($items) < $max_imagesOtherwise we get true and display the you must delete form all the time.
Comment #19
jpetso commentedOops... I did that in yesterday's patch, but forgot to redo it while reconstructing that one (and of course failed to test the last one that I posted). So your version is now really nice and correct - I'll justify marking it as RTBC with the new "reviewed and tested by the community" meaning. Great teamwork :)
Comment #20
bomarmonk commentedI have tested this latest patch and it solved my problem. Bravo.
Comment #21
Anonymous (not verified) commentedmy apologies.
Comment #22
Mark Theunissen commentedPatch works for me too!
Comment #23
shane birley commentedPatched and tested on Drupal 5.7 with ten different sites. Patch appears to have worked great!
Comment #24
dopry commentedcommitted to DRUPAL-5--2. Thanks guys!!
Comment #25
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.