When the user clicks remove to change the image to crop the image is still left under the filefield.
This only seems to happen if the form already has a previous image saved in a node.

It would logical that if you click remove, all traces of the image would be removed from the form.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mr.alinaki’s picture

I approve - this is not very good behaviour :)

Bilmar’s picture

I am experiencing the same problem and came across this post. Is this as per design?
I hope it is something that can be looked at and I will be the first to test to give feedback =)

Thank you in advance!

rburgundy’s picture

subscribing - I think this causes confusion to end-user if their picture was in fact actually removed (if it still shows after they press the remove button)

rburgundy’s picture

FileSize
35.46 KB

image attached to show issue mentioned.
please let me know if anymore details are required.

thanks

OneTwoTait’s picture

FileSize
31.16 KB

Same here.

Plus, after removing, saving, and returning to the edit page, the full image is there. Actually there are two full images stacked one on top of another, but one is all black except for the part in the crop box.

After refreshing the page, there is no image.

This image is from Firefox 3.

OneTwoTait’s picture

FileSize
213.02 KB

Oops, wrong image.

Here is the actual beautiful image from the website.

rburgundy’s picture

I am still experiencing this issue. I am guessing others as well? More comments may help bring this issue to the surface =)

waxb’s picture

any updates on this?

robby.smith’s picture

this is still happening with the latest dev =(

sydneyshan’s picture

Version: 6.x-1.0-beta3 » 6.x-1.0-rc2

This is still happening with 6.x-1.0-rc2

Any chance of a bug fix on this one?

I'm encountering it with an 'unlimited' imagefield upload list - it may well work on a single/limited imagefield upload list?

bnfan’s picture

Yes, this is also happen on our site. Very ugly bug, we have no method to fix it.

When will this bug be fixed!

aether’s picture

Not a proper fix but I needed a quick solution. Works for my current purposes (single images, not sure how it would work with multiples).

Place this in a module or theme's javascript file:

$('.jcrop-preview-wrapper').each( function() {
  if (!$(this).parents('.widget-preview').length) {
    $(this).remove();
  }
});
bnfan’s picture

Thank you aether, it works for us!

drupalprojects’s picture

I think i've found a proper way to fix it. I've tried to narrow down the problem and found that hook_widget_value was invoked before the actual file delete and we don't check if remove button was clicked in imagefield_crop_widget_value. This lead to some problems:
1) _imagefield_crop_resize invoked on remove event. In my case (my images is huge) this lead to memory issues on th server
2) problem, described by previous authors.

So a quick fix from me:

      $element['filefield_remove'] = array(
      // With default CCK edit forms, $element['#parents'] is array($element['#field_name'], $element['#delta']).
      // However, if some module (for example, flexifield) places our widget deeper in the tree, we want to
      // use that information in constructing the button name.
      '#name' => implode('_', $element['#parents']) .'_filefield_remove',
      '#type' => 'submit',
      '#value' => t('Remove'),
      '#submit' => array('node_form_submit_build_node'),
      '#ahah' => array( // with JavaScript
        'path' => 'filefield/ahah/'.   $element['#type_name'] .'/'. $element['#field_name'] .'/'. $element['#delta'],
        'wrapper' => $element['#id'] .'-ahah-wrapper',
        'method' => 'replace',
        'effect' => 'fade',
      ),
      '#field_name' => $element['#field_name'],
      '#delta' => $element['#delta'],
      '#weight' => 101,
      '#post' => $element['#post'],
    );
    if (_form_button_was_clicked($element['filefield_remove'])) return;

Should be added right after if ($edit) { in imagefield_crop_widget_value

quadbyte’s picture

Status: Active » Needs review
FileSize
1.06 KB

Seems to me it's a major UX problem. I'm not too found of the fix in #14 but it seems to be the best as of today. Attached a patch for review.

amitaibu’s picture

@quadbyte,

Haven't tested yet, but patch seems to take the right approach. I'd change the docs a bit, though, and copy from filefield:

  // Because the output of this field changes depending on the button clicked,
  // we need to ask FAPI immediately if the remove button was clicked.
  // It's not good that we call this private function, but
  // $form_state['clicked_button'] is only available after this #process
  // callback is finished.
  // This is also used in filefield_widget_process().
YK85’s picture

+1 subscribing

pcambra’s picture

#15 Works for me
I'm attaching the patch with the filepath fixed and the docs suggested by #16

paulbeaney’s picture

Applied the patch in #18 - works fine for me. Thanks very much.

Regards,

- Paul

YK85’s picture

Status: Needs review » Reviewed & tested by the community

this patch helped with my problem as well.
thank you

Naiya’s picture

I think that this thumbnail is ok, maybe it should be a task - an administrative option/checkbox if we want or don't want this thumb?

YK85’s picture

It is strange for a thumbnail to remain on the page after Remove was clicked by the user. It definitely looks like a bug from an end-user perspective, as when they choose a different image and upload the lingering thumbnail then disappears. What does everyone else think?

sydneyshan’s picture

I definately agree - it makes no logical sense for this thumbnail to remain.

univate’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
816 bytes

I fixed this using a slightly more generic method by checking if '#access' variable on the element.

univate’s picture

Actually that previous patch caused some regressions, I also noticed there was some code that was attempting to check for the remove button but not working so this is a re-worked patch.

Open Social’s picture

last patch works fine!

nampham’s picture

Thank you so much, it works for me.

muldos’s picture

Thanks, I run into the same issue and the latest patch works for me too !
For themes putting all their scripts just before page closure, I made a patch (http://drupal.org/node/962382#comment-4900678) that solve both issues.