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

allow omission of height from image subroutine and preserve aspect ratio #316

Merged
merged 1 commit into from
Aug 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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