debugged the screenshot helper, should work for all conditions and has default height and width as a backup for an unforeseen case
This commit is contained in:
parent
b86727d359
commit
ca8077dec8
2 changed files with 19 additions and 12 deletions
|
@ -9,21 +9,28 @@ module ScreenshotHelper
|
||||||
## Outputs:
|
## Outputs:
|
||||||
## Size array of 'width' and 'height'
|
## Size array of 'width' and 'height'
|
||||||
##
|
##
|
||||||
size = nil
|
|
||||||
if (fwidth >= fheight) then
|
if (fwidth >= fheight) then
|
||||||
if (fwidth[0] >= max) then
|
if (fwidth >= max) then
|
||||||
size[width] = max
|
width = max
|
||||||
|
height = ((fheight / fwidth.to_f) * max).to_i
|
||||||
else
|
else
|
||||||
size[width] = fwidth
|
width = fwidth
|
||||||
|
height = fheight
|
||||||
end
|
end
|
||||||
else
|
elsif (fheight > fwidth) then
|
||||||
if (fheight >= max) then
|
if (fheight > max) then
|
||||||
size[height] = max
|
height = max
|
||||||
size[width] = (( fwidth / fheight.to_f ) * max).to_i
|
width = (( fwidth / fheight.to_f ) * max).to_i
|
||||||
else
|
else
|
||||||
size[height] = fheight
|
height = fheight
|
||||||
|
width = fwidth
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
width = fwidth
|
||||||
|
height = fheight
|
||||||
end
|
end
|
||||||
|
|
||||||
return [width, height]
|
return [width, height]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<% size = size_calc(@fsize[0], @fsize[1], 500) %>
|
<% size = size_calc(@fsize[0], @fsize[1], 600) %>
|
||||||
|
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="border" style="width:<%= size[width] %>;">
|
<div class="border" style="width:<%= size[0] %>;">
|
||||||
<%= image_tag @fpath , :width => size[width] , :height => size[height] %>
|
<%= image_tag @fpath , :width => size[0] , :height => size[1] %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
Loading…
Reference in a new issue