Skip to content

Commit

Permalink
Merge pull request #316 from Alex-Jordan/image-aspect-ratio
Browse files Browse the repository at this point in the history
allow omission of height from image subroutine and preserve aspect ratio
  • Loading branch information
mgage authored Aug 2, 2017
2 parents f5957ff + 27e1f7c commit a140ed5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions macros/PGbasicmacros.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2689,7 +2689,7 @@ sub image {
my %in_options = @opt;
my %known_options = (
width => 100,
height => 100,
height => '',
tex_size => 800,
extra_html_tags => '',
);
Expand All @@ -2709,6 +2709,11 @@ sub image {
my $width_ratio = $tex_size*(.001);
my @image_list = ();

# if height was explicitly given, create string for height attribute to be used in HTML, LaTeX2HTML
# otherwise omit a height attribute and allow the browser to use aspect ratio preservation
my $height_attrib = '';
$height_attrib = qq{height = "$height"} if ($height);

if (ref($image_ref) =~ /ARRAY/ ) {
@image_list = @{$image_ref};
} else {
Expand Down Expand Up @@ -2741,7 +2746,7 @@ sub image {
}
} elsif ($displayMode eq 'Latex2HTML') {
my $wid = ($envir->{onTheFlyImageSize} || 0)+ 30;
$out = qq!\\begin{rawhtml}\n<A HREF= "$imageURL" TARGET="_blank" onclick="window.open(this.href,this.target, 'width=$wid,height=$wid,scrollbars=yes,resizable=on'); return false;"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A>\n
$out = qq!\\begin{rawhtml}\n<A HREF= "$imageURL" TARGET="_blank" onclick="window.open(this.href,this.target, 'width=$wid,height=$wid,scrollbars=yes,resizable=on'); return false;"><IMG SRC="$imageURL" WIDTH="$width" $height_attrib></A>\n
\\end{rawhtml}\n !
} elsif ($displayMode eq 'HTML_MathJax'
|| $displayMode eq 'HTML_dpng'
Expand All @@ -2754,7 +2759,7 @@ sub image {
my $wid = ($envir->{onTheFlyImageSize} || 0) +30;
$out = qq!<A HREF= "$imageURL" TARGET="_blank"
onclick="window.open(this.href,this.target, 'width=$wid,height=$wid,scrollbars=yes,resizable=on'); return false;">
<IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height" $out_options{extra_html_tags} >
<IMG SRC="$imageURL" WIDTH="$width" $height_attrib $out_options{extra_html_tags} >
</A>
!
} else {
Expand Down

0 comments on commit a140ed5

Please sign in to comment.