When "Manually Upload a thumbnail" is checked, uploading or removing a video thumbnail results in this error although the upload is successful.

I believe this is as the thumbnail field is added by the '#process' on the widget and as such when file_ajax_upload retrieves the form from the cache it does not contain the "thumbnail" field. As such when it attempts get the current element and count the number of files it cannot find the field resulting in the error provided in the title.

I believe the upload works as the current file count defaults to zero in file.module, however, this may have some knock on effects with multiple file fields on the same page (although I cannot vouch for this as I have not tested and don't know the workings well enough).

Either way this error is annoying and can be fixed by ensuring video_field_widget_form includes the 'thumbanail' field.

My quick fix at ln305 of video.field.inc was

if(!isset($elements[$delta]['thumbanail'])){
     	$elements[$delta]['thumbanail'] = array(
     	        '#type' => 'value',
     	        '#value' => NULL,
     	);
}

however, I'm not sure what knock on effects this has (as it still doesn't set the element count that file_ajax_upload is looking for) and I'm sure the maintainer will be able to solve this more satisfactorily.

Cheers,
Lewis

Comments

loominade’s picture

I have the same error which seems to be connected with #1233604: Thumbnails are dissappearnig.

the following error appears on uploading a thumbnail manually or deleting an existing thumbnail:

 Notice: Undefined index: thumbanail in file_ajax_upload() (line 256 of ../modules/file/file.module).
    Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of ../includes/entity.inc).

after saving i get this:

 Notice: Undefined index: thumbanail in file_ajax_upload() (line 256 of ../modules/file/file.module).
    Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of ../includes/entity.inc).
hypertext200’s picture

cclafferty’s picture

Status: Closed (duplicate) » Active

I am also receiving this error however I have reopened this issue as I am not experiencing the "array flip" problem which others are claiming. Simply put, I get this exact error:

Notice: Undefined index: thumbnail in file_ajax_upload() (line 256 of /var/www/supponor.com/dev/htdocs/modules/file/file.module).

I have manual upload of thumbnails enabled and using zencoder as my transcoder. Any interaction with the thumbnail field shows the above error. Adding a thumbnail or removing it.

I am also having issues with thumbnails disappearing. I go to edit the content after they disappear and the thumbnail field is empty with the words "Remove" as its button action. I've tried running cron to see if there's a hook deleting my images but there is none. I have no idea how this is happening however I intend to spend a few hours today finding out.

hypertext200’s picture

Status: Active » Fixed

Please upgrade to the latest version.

cclafferty’s picture

Great job with the new version hashan, the ffmpeg version information pulls through correctly now which is great. Unfortunately the new version does not correct the problem with the undefined index or the disappearing thumbnail images.

I did however find the problem with our disappearing images. Manually uploaded thumbnails are set to TEMPORARY. Turns out video_field_presave in video.field.inc doesn't care for a thumbnail value. It only checks if we've set a default thumbnail or not. When passing $items onto file_field_presave the thumbnail property is simply ignored. Hence on a cron run the these temporary thumbnails are deleted.

Here is my crude fix which I have just gotten working 5 mins ago. It just ensures we have new items for our thumbnails for the file_field_presave to make PERMANENT.

Add this under line 138 of video.field.inc version 7.x-2.2-beta4


    // Manually uploaded a thumbnail.
    if ($item['thumbnail'] && !$item['use_default_video_thumb']) {
      $items[] = array(
        'fid' => $item['thumbnail'],
      );
    }

Still having problems with the previous error though. Will post back if I find anything.

// Edit: Changed code to reflect patch

hypertext200’s picture

Version: 7.x-1.0-alpha2 » 7.x-2.2-beta4

Nice work around, could you please provide a patch?

cclafferty’s picture

Status: Fixed » Active

Disappearing thumbnail patch is here: #1233604: Thumbnails are dissappearnig
Undefined index error still exists as a separate issue.

hypertext200’s picture

Please see #1067470: PHP notice on AJAX upload for file_managed fields added during element #process callback this is a core issue you can apply that patch and fix that notice.

hypertext200’s picture

Status: Active » Closed (won't fix)
dealancer’s picture

Status: Closed (won't fix) » Needs work

This error happens even when uploading file on post and not on AJAX request.

I have following error message when clicking Save button:

Notice: Undefined index: #field_name in file_managed_file_save_upload() (line 630 of /var/www/site/modules/file/file.module).
The file could not be uploaded.
andypost’s picture

Version: 7.x-2.2-beta4 » 7.x-2.x-dev

And there's no notice in core's file upload widget

Jorrit’s picture

Status: Needs work » Active
Jorrit’s picture

Status: Active » Fixed

This issue has been fixed as part of #1441626: thumbnail are not added in file_usage table.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.