Issue #943924 by Merco, lotyrin, eojthebrave: Fixed Allow preview of private image on node add form.
parent
826ae5ac4e
commit
37f1878633
|
@ -142,10 +142,14 @@ function file_file_download($uri, $field_type = 'file') {
|
||||||
// Find out which (if any) fields of this type contain the file.
|
// Find out which (if any) fields of this type contain the file.
|
||||||
$references = file_get_file_references($file, NULL, FIELD_LOAD_CURRENT, $field_type);
|
$references = file_get_file_references($file, NULL, FIELD_LOAD_CURRENT, $field_type);
|
||||||
|
|
||||||
// If there are no references, stop processing, to avoid returning headers
|
// Stop processing if there are no references in order to avoid returning
|
||||||
// for files controlled by other modules.
|
// headers for files controlled by other modules. Make an exception for
|
||||||
if (empty($references)) {
|
// temporary files where the host entity has not yet been saved (for example,
|
||||||
return;
|
// an image preview on a node/add form) in which case, allow download by the
|
||||||
|
// file's owner.
|
||||||
|
|
||||||
|
if(empty($references) && ($file->status == FILE_STATUS_PERMANENT || $file->uid != $user->uid)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default to allow access.
|
// Default to allow access.
|
||||||
|
|
Loading…
Reference in New Issue