Needs review
Project:
File Entity Paths
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Nov 2013 at 20:36 UTC
Updated:
5 Sep 2018 at 19:58 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
PascalAnimateur commentedComment #2
matt.mendonca commentedQuick patch against 2013-09-30 dev release. Uncheck the new box on the FE paths config page to allow filename changes to file entities to saved.
Comment #3
sgdev commentedThe problem I see is what is referenced in the original post (https://www.drupal.org/project/file_entity/issues/2074625).
When the file entity is initially created, editing the filename has no effect because the file does not yet exist. Either it uses the default filename, or it follows the FE Paths rules if it exists. Once the file is saved, I can re-edit the file and change the filename without issue.
Is there something else I am missing? If there was going to be a patch, I think a better way to handle would be doing this behind the scenes instead of a checkbox.
Check if there is a difference between $file->filename and the file name generated by FE Paths. If they are the same, keep going. If not, override using the $file->filename value.
Comment #4
sgdev commentedI just saw this comment in the patch: "This means a user cannot rename the file entity later."
I'm not seeing that at all. Once the file entity is saved, I can edit it and change the file name to something completely different than the FE Paths default.
You might want to try upgrading to the latest version of File Entity and see if some issues are resolved, since there is a fairly new "Keep original filename" setting now available.
Comment #5
sgdev commentedI've done some more investigation and see how this is an issue. However, there are a couple of problems with skipping
$object->filenameas is done in patch #2.First, this causes the FE Paths filename settings to be ignored entirely, and just retains the original name of the file. Second, it creates a situation where the URL is rendered with an extra slash ("/") when it shouldn't be.
Attached is a slightly different patch for review. This patch does the following:
* Sets a separate checkbox option for each file type.
* Passes the checkbox values into the global FE Paths config settings.
* If the checkbox is set, re-save the file with the filename passed in through the
$fileobject prior to returning.Comment #6
sgdev commentedFound a bug with patch #5. The value of
$config_data['override_file_entity_name']will not be set if the file being processed is part of a custom FE Path (not one of the defaults like image, video, etc.).Therefore need to add an extra check to see if the value
isset, otherwise will display an error message.See the attached update, thanks.