Editing a node with CCK image_fupload widget in single upload mode produces javascript error

fearlsgroove - May 17, 2009 - 18:53
Project:Image FUpload
Version:6.x-3.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

The image_fupload CCK widget bails in favor of the standard image upload widget when editing an existing node:

<?php

     
// standard image fupload form; will be shown in the most cases (not for existing node in single mode)
     
if (isset($form['#node']->nid) && $field['widget']['fupload_mode'] == "single") {
       
// don't create fupload form
?>

which makes sense. However the swfupload-settings.tpl.php gets included regardless. Since the span '#spanUploadButton' never gets added to the form, this produces a JS error:
uncaught exception: Could not find the placeholder element: spanUploadButton

The attached patch does two things:

  • it uses Drupal.behaviors to initalize the swfupload object instead of window.unload, which shouldn't be used anymore, and
  • It does a simple check to see if #spanUploadButton exists, and doesn't try to create the swfupload object if not
AttachmentSize
image_fupload-edit-js-error.patch1.04 KB

#1

grandcat - May 17, 2009 - 20:11

Thank you, I will check this one.

 
 

Drupal is a registered trademark of Dries Buytaert.