$file->update($data = array()[, $language])

Updates the meta information for a file

  • $data (array)
  • $language (string)
    Language code
  • return ($file)

Example

$file = $page->file('myimage.jpg');

try {

  $file->update(array(
    'caption' => 'This is a really nice image',
    'year'    => 2014
  ));

  echo 'The meta info has been updated';

} catch(Exception $e) {

  echo 'The meta info could not be updated';
  // optional reason: echo $e->getMessage();

}

Multi-language installation

In a multi-language installation, you can pass the language of the meta data you want to update as a second argument:

$page->file('some-file.jpg')->update(array(
  'some_field' => 'new value'
), 'en');

$page->file('some-file.jpg')->update(array(
  'some_field' => 'new value'
), site()->language()->code());