Closed (fixed)
Project:
Media Manager
Version:
5.x-0.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
19 Dec 2007 at 10:37 UTC
Updated:
12 Jan 2008 at 03:33 UTC
I would like to add a metadata field when doing bulkimporting. This is easy enough, I just add 'source'=>'Copyright owner' to the metadata array.
What I would also like though, is the ability to manually edit it on a per media instance basis. Could we have either
a) settings for what kinds of metadata we use, or
b) edit media show a textfield for all metadata belonging to the current media instance?
If you deem it worthwhile, I could submit a patch for b).
Comments
Comment #1
rhys commentedThere is already a way to simply and easily add extra metadata information to the media, I simply haven't added all the major ones that I planned to have in there. source will definitely be in there, but as yet, I haven't had a chance to add all the really cool things.
Also, I'm changing the structure of the entire module to be much more general, as well as easier to manage.
This includes isolating somewhat the API, so that module developers (such as yourself), can do their job in a nice clean way :).
I'd be very interested in seeing what you've written for the bulk import module, since I'd like to add that function to this module.
Comment #2
Ibn al-Hazardous commentedFor bulk importing I wrote this one:
****
function _att_media($filename, $nid, $source, $title)
{
global $debug_am;
$debug_am.="Importing and attaching $filename\n";
$clean_title=preg_replace("/\s+/"," ",$title);
$clean_source=preg_replace("/\s+/"," ",$source);
$metadata=array('title'=>$clean_title, 'source'=>$clean_source);
if (!$media=media_item_create($filename)){
$debug_am.="Failed to create media item\n";
return false;
}
$der_list=media_derivatives_by_ext($media->ext);
foreach($der_list as $der_name){
$debug_am.="Creating $der_name \n";
if ($name=media_derive($media->mid, $der_name, true,true,false)){
$debug_am.="$name\n";
}else{
$debug_am.="failed...\n";
}
}
media_item_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 );
return true;
}
****
Apart from dumping $debug_am in the footer, inside a pre-tag there's nothing strange here.
I discovered that copying the importee to the dir returned by file_directory_temp() - and submitting the filename as $tmp_dir."/".basename($filename) is a requirement to get media_file_copy working (submitting a filename with path relative to $drupal_root was not enough).
This function is called after I have imported my story data into a node (since we need the nid).
Comment #3
rhys commentedIf you want a specific metadata to exist, and be editable simply through the browser, you need to create a module which has the following within it.
I'll be documenting things a bit more clearly in the API, especially once it gets closer to completion.
Hopefully this helps, but I'll also be uploading a heavily modified version of the module on Jan 1.
Comment #4
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.