Skip to content

Commit

Permalink
Specify video_height: false behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
paneq committed Aug 29, 2013
1 parent e42b0df commit 4fd768b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/embedda/filters/vimeo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def process(string)
private

def player(token)
%Q{<iframe src="#{player_url(token)}" width="#{@width}" height="#{@height}" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>}
%Q{<iframe src="#{player_url(token)}" width="#{@width}"#{height_attribute} frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>}
end

def player_url(token)
Expand All @@ -30,6 +30,10 @@ def player_url(token)
url.query = Rack::Utils.build_query @vimeo_url if @vimeo_url
url.to_s
end

def height_attribute
%Q{ height="#{@height}"} if @height
end
end
end
end
7 changes: 7 additions & 0 deletions spec/embedda_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
let(:https_embed_string) { embed_string.gsub("http", "https") }
let(:horizontal_embed_string) { embed_string.gsub("560", "200").gsub("315", "400") }
let(:query_string_embed) { embed_string.gsub("20241459", "20241459?title=0&byline=0&portrait=0&color=42b7ed") }
let(:no_height_embed) { embed_string.gsub(%q{height="315" }, "") }

it "should embed when text have a link" do
@story = "http://vimeo.com/20241459"
Expand Down Expand Up @@ -118,6 +119,12 @@
embedda = described_class.new(@story, :vimeo_url => {:title => 0, :byline => 0, :portrait => 0, :color => "42b7ed"}).embed
expect(embedda).to eq(query_string_embed)
end

it 'generates iframe without height attribute when height is falsy' do
@story = "http://vimeo.com/20241459"
embedda = described_class.new(@story, :video_height => false).embed
expect(embedda).to eq(no_height_embed)
end
end

context "Soundcloud-link" do
Expand Down

0 comments on commit 4fd768b

Please sign in to comment.