In my case, this is exactly: I'm using media_youtube in a field. In this, I've enabled upload image, or embed youtube video. When upload a youtube video, the file display completely broken, because of moving files.

These should be solutions:
1. Only process file, it has own extension.
It works with embed video in my case, but the question is: Uploaded files without extension always need to skip ffp process?

2. Add field to ffp administration, where user can edit the exceptions of ffp process, eg can set some file filemime.

3. Other modules what provides this type if files need to use hook_filefield_paths_process_file() to set $file['new'] always false.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

szantog’s picture

Status: Active » Needs review
FileSize
743 bytes

And a patch for option 1.

Dave Reid’s picture

Probably the module shouldn't process any remote files. The file_entity module provides a file_entity_file_is_local() whose code could be re-used for this purpose.

jacobpov’s picture

Priority: Normal » Critical
Status: Needs review » Needs work

because of this it broke my embed field none of the new nodes worked. instread of processing the URL right it made some file and renamed it instead of outputting the video itself. there has to be some disable button for a specific field to save from those problems.

I haven't tested the uploaded patch but it sounds like not the best solution , perhaps disable button for a field would be better?

jacobpov’s picture

ok patch can no longer be applied to the news versions .... I will disable file field paths for now .

szantog’s picture

Yes, you are right. But since then a lot of things happened.

jacobpov’s picture

yeah but its something different .. I was looking to use this module not other that works with enteties

bkat’s picture

I'm having the same issue and I've hacked around it by bailing out of filefield_paths_filefield_paths_process_file() if the file's uri starts with "youtube://". Obviously not a real solution but it has gotten me past the problem for my site.

burningdog’s picture

I have a similar issue. I'm using Remote File Source to allow a file entity to be a full url, like http://www.example.com/path/to/remote/file.jpg

This works fine, until Filefield Paths is enabled - then the file is copied locally and the uri changes to something like public://file.jpg (if no replacement pattern is defined the file is still copied locally).

Like the posters above, I need some way to either:

* NOT call filefield_paths_filefield_paths_process_file()
* exit filefield_paths_filefield_paths_process_file() on certain conditions.

I tried playing with hook_module_implements_alter() to unset the value of "filefield_paths" when filefield_paths called <?php foreach (module_implements('filefield_paths_process_file') as $module) {?> but turns out that hook only allows changing the weight value, not stopping a call to an undesired function. I don't know if there is a way to stop module_implements from returning "filefield_paths".

The simplest idea seems to be to add an additional checkbox to the Filefield Path settings for a particular field called "Skip processing the file", check it, and then add a check for that here:

<?php
<?php
function filefield_paths_filefield_paths_process_file($type, $entity, $field, $instance, $langcode, &$items) {
  if (isset($instance['settings']['filefield_paths'])) {
    $settings = $instance['settings']['filefield_paths'];
    // Here is the added code
    if ($settings['skip_process_file']) {
      drupal_set_message('GET THE HELL OUT OF HERE!');
      return;
    }
?>

This works, but I'm not sure if it's the most elegant solution. Patch coming.

burningdog’s picture

Status: Needs work » Needs review
FileSize
1.55 KB

Patch attached.

burningdog’s picture

Here's a better solution, proposed by Dave Reid in #2, i.e. don't process any non-local files. This introduces a dependency on file_entity because of the call to file_entity_file_is_local().

burningdog’s picture

file_entity_file_is_local() is just 3 lines of code - is it really worth introducing a dependency for those 3 lines? Rather, let's copy that function into filefield_paths and use it instead: filefield_paths_uri_is_local()

burningdog’s picture

Title: Another media problem: Some of file types never should be processed by ffp. » Remotes files should not be processed

Title change.

jaydub’s picture

Happy I found this ticket. This is exactly what I was looking for. Applied patch and remote URLs are not being hit now.

ju.ri’s picture

Any chance for a D6 patch? Thanks!!

Deciphered’s picture

Status: Needs review » Needs work
+++ b/modules/filefield_paths.incundefined
@@ -45,6 +45,9 @@ function filefield_paths_filefield_paths_process_file($type, $entity, $field, $i
+        break;

This seems like flawed logic to me, break means it will stop the foreach loop, which means if there happens to be any files after this file that are local they will never be processed.

 

Happy to make the changes myself and give you credit in the changelog and commit message, or let you fix the patch and get the commit attribution.

Cheers,
Deciphered.

dwkitchen’s picture

The patch did what I needed as my site doesn't mix local and remote files in the same field.

Agreed it should be something like:

if (filefield_paths_uri_is_local($file['uri'] && ($file['timestamp'] == REQUEST_TIME || $settings['active_updating'])) {
Deciphered’s picture

Status: Needs work » Fixed

Fixed and committed.

Thanks all.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

.