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:
|
||||
## Size array of 'width' and 'height'
|
||||
##
|
||||
size = nil
|
||||
|
||||
if (fwidth >= fheight) then
|
||||
if (fwidth[0] >= max) then
|
||||
size[width] = max
|
||||
if (fwidth >= max) then
|
||||
width = max
|
||||
height = ((fheight / fwidth.to_f) * max).to_i
|
||||
else
|
||||
size[width] = fwidth
|
||||
width = fwidth
|
||||
height = fheight
|
||||
end
|
||||
else
|
||||
if (fheight >= max) then
|
||||
size[height] = max
|
||||
size[width] = (( fwidth / fheight.to_f ) * max).to_i
|
||||
elsif (fheight > fwidth) then
|
||||
if (fheight > max) then
|
||||
height = max
|
||||
width = (( fwidth / fheight.to_f ) * max).to_i
|
||||
else
|
||||
size[height] = fheight
|
||||
height = fheight
|
||||
width = fwidth
|
||||
end
|
||||
else
|
||||
width = fwidth
|
||||
height = fheight
|
||||
end
|
||||
|
||||
return [width, height]
|
||||
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="border" style="width:<%= size[width] %>;">
|
||||
<%= image_tag @fpath , :width => size[width] , :height => size[height] %>
|
||||
<div class="border" style="width:<%= size[0] %>;">
|
||||
<%= image_tag @fpath , :width => size[0] , :height => size[1] %>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in a new issue