I'm using Drupal 7 with module EXIF. I want to check if uploaded photo have EXIF data if not then don't allow the user to add this content.


If you want to check a file that is being added through a file field on a content type you can use hook_node_presave. Unless you need the exif module for other reasons you can do without this module and just use the exif_read_data function. Make sure to enable to the exif extension in php.

function mymodule_node_presave($node) {
  if ($node->type == 'article') {
    // Still needs some checking here to see if a file is provided
    $fid = $node->field_file['und'][0]['fid'];
    $file = file_load($fid);
    $hasExif = exif_read_data($file->uri, 0, true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.