I have set the folders up, but the images all land i files/0 (including derivatives).

This is the import snippet:

  $metadata=array('title'=>$clean_title, 'source'=>$clean_source);
  if (!$media=media_item_create($filename)){
    $dump.="...media_item_create failed".print_r($media,TRUE);
    return false;
  }
  $der_list=media_derivatives_by_ext($media->ext);
  foreach($der_list as $der_name){
    $dump.="Creating derivative $der_name\n";
    if ($name=media_derive($media->mid, $der_name, true,true,false)){
      $dump.="$name\n";
    }else{
      $dump.="Failed...\n";
    }
  }
  media_metadata_save($media->mid, $metadata);

  db_query( "INSERT INTO {media_attachments} "
    ."(nid,mid,weight,caption,flags,visible) VALUES (%d,%d,%d,'%s',%d,%d)",
    $nid, $media->mid, 0, $clean_title, 0, 1 );

(Where as usual $dump is my logging facility, which can safely be ignored.)

I'm not sure what's the problem here. Is it that $fid=0 is interpreted literally?

Comments

rhys’s picture

Status: Active » Fixed

The problem here is the variable changed when I rearranged the system.
If you change save the details for the media directory (via settings), you shouldn't keep having this problem.

Ibn al-Hazardous’s picture

Seems right.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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