Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I am trying to access the upload button of an Image field. The field itself is in a field collection. Using dpm, I can access the field collection, and the image field.

What I want is to create a callback for the upload button such that once the upload is complete, the callback is triggered (ultimately to call a js function). I have found a few articles on how to do this for custom made, from scratch forms, but very little, and nothing yet that seems to work for me on existing, core forms.

I have been racking my brain for a couple of hours looking through elements via dpm, and researching, but I haven't found any fruitful examples related to this particular use-case.

I also tried tinkering with hook_field_widget_form_alter, which triggers for each element on every load, including initial load. I haven't been able to narrow it down to just the one event yet.

I went a completely different way as well, trying to intercept the click on the input via jQuery, which would then use a timer to check for the uploaded file in the new DOM output, and continue if found, but I cant get the click to work - I don't know if the built in ajax is over-ruling my code, or just a big conflict is causing it to fail for my own code.

Does anyone have any suggestions or direction on where I should look next?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You can try hook_file_presave() or hook_file_insert() or hook_file_update()

share|improve this answer
    
this did work, but I ended up going a different direction anyways... –  Geoff Jun 15 '14 at 3:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.