When setting up a file field to use ONLY remote youtube links, you can't leave the "Allowed file extensions for uploaded files" field blank (it's required).
If I don't want to allow local files, this is not possible.

Also, when creating a node that includes the filefield, there is always still the option to upload a file (which is not desirable).

CommentFileSizeAuthor
#8 Selection_012.jpg150.84 KBjhedstrom
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rootwork’s picture

Title: Can't ONLY allow remote youtube files for field » Restrict field to only web videos; remove/hide file upload sections

Agreed, this is confusing. It seems like the current functionality is keyed off of a file upload (although the field type, while categorized under file, is helpfully described as a "media file selector" rather than a "media file upload," which I appreciate!).

The current setup means:

  • Adding the field is confusing, because you have to first pick an "upload destination," even if you only want to allow access to videos already on YouTube.
  • You see a "file (field) path settings" section, even if you don't ever want any videos uploaded.
  • You have to provide at least one type of allowable upload file type (defaults to .txt).
  • As noted by the OP, when clicking on the button for that field in a node form, you get "upload," "web," and "library" tabs, defaulting to "upload," even though all you want is "web."

I guess the field was built to allow people to upload videos and choose videos from the web, which is great flexibility! But it would also be nice to have the flexibility of restricting the field to web videos alone.

rootwork’s picture

Project: Media: YouTube » D7 Media
Component: User interface » Media Internet

Sorry, I realized this is really a core Media module issue. I'm moving it over to that queue.

psychobyte’s picture

Anyone know of a quick work around to this issue?

psychobyte’s picture

NVM. with media-2.x you can select what plugins you want to allow.

sumitmadan’s picture

I want same functionality but I want to hide web tab if I don't select youtube option. Any progress????

J_Andres’s picture

Friends, some solution for this?

thanks,

inversed’s picture

Issue summary: View changes

I'm not sure how this is handled in Media 2 (per this issue) but there is a solution to hide the Upload tab that is working in my Media 1 implementation. It may be adaptable to the other tabs. You can see it here: https://drupal.org/node/1281486

jhedstrom’s picture

FileSize
150.84 KB

I have a use case that cannot be resolved by hiding the upload tab: we need the WYSIWYG media browser to allow *image* and *document* uploads, but only allow videos from the *web* tab (disallowing direct video upload, but allowing youtube/vimeo). With the latest media 2, there doesn't appear to be any way to configure allowed extensions independent of allowed types

jhedstrom’s picture

I was able to hack around the issue using a form alter to remove video types from the upload tab, yet still allow web uploads:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function MYMODULE_form_file_entity_add_upload_alter(&$form, $form_state) {
  // Strip out any video types from allowed extensions. We cannot use normal
  // configuration for this since that would also disallow video in the 'Web'
  // tab. See https://drupal.org/comment/8584897#comment-8584897.
  $video_types = explode(' ', 'mp3 mov mp4 m4a m4v mpeg avi ogg oga ogv weba webp webm');
  $allowed_extensions = $form['upload']['#upload_validators']['file_validate_extensions'][0];

  foreach ($video_types as $extension) {
    $allowed_extensions = str_replace($extension, '', $allowed_extensions);
    $allowed_extensions = str_replace('  ', ' ', $allowed_extensions);
  }

  $form['upload']['#upload_validators']['file_validate_extensions'][0] = $allowed_extensions;
}
Dave Reid’s picture

Status: Active » Fixed

As per the screenshot in #8 we added the ability to hide certain media browser tabs, which I think fulfills the original requirement. We can't really handle the advanced logic requested in #8, so custom validation is definitely the way to go (as said in #9).

Status: Fixed » Closed (fixed)

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

jaykainthola’s picture

Hi,

I am also facing same issue. Have anyone found the solution for same?

Thanks