Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validations for <audio> and<source>... #45

Open
Pjero opened this issue Apr 22, 2017 · 1 comment
Open

Validations for <audio> and<source>... #45

Pjero opened this issue Apr 22, 2017 · 1 comment

Comments

@Pjero
Copy link

Pjero commented Apr 22, 2017

Can you please add attribute validations for and so links to audio files can have controls and be listened from the browser.
I tried to add them in validators.js.erb, but nothing seems to work. I had ta add the tags with JS.
This what I've added to validators.js.erb:

 "audio": {
      "attributes":[
        "controls"
      ]
    },
"source": {
      "attributes":[
        "src"
      ]
    },
@evenreven
Copy link
Contributor

Stumbled across this. I assume you've found a different solution after almost six years, but for anyone googling this...

You don't need to edit the validators.js.erb file, you can set overrides in your own app through the initializer. Be advised that if you use whitelist_tags, then you need to whitelist every attribute (the docs say something subtly different, but in my experience this was necessary). Like this:

# config/initializers/refinery/wymeditor.rb
Refinery::Wymeditor.configure do |config|
# SNIP
  config.whitelist_tags = {
    "audio" => { "attributes": { "0": "controls", "1": "src" } }
  }
# SNIP
end

The other catch is that wymeditor won't accept empty attributes at all, so you have to trick it by adding ="true". Like this:

<audio controls="true" src="/media/cc0-audio/t-rex-roar.mp3">
  <a href="/media/cc0-audio/t-rex-roar.mp3">Download audio</a>
</audio>

I discovered this when I was trying to use <iframe allowfullscreen> with youtube videos and found out the only way was using <iframe allowfullscreen="true">.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants