Skip to content
Snippets Groups Projects
Commit 37f18786 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #943924 by Merco, lotyrin, eojthebrave: Fixed Allow preview of private...

Issue #943924 by Merco, lotyrin, eojthebrave: Fixed Allow preview of private image on node add form.
parent 826ae5ac
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -142,9 +142,13 @@ function file_file_download($uri, $field_type = '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);
// If there are no references, stop processing, to avoid returning headers
// for files controlled by other modules.
if (empty($references)) {
// Stop processing if there are no references in order to avoid returning
// headers for files controlled by other modules. Make an exception for
// temporary files where the host entity has not yet been saved (for example,
// 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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment