<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=AutomaticImageResize</id>
	<title>AutomaticImageResize - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=AutomaticImageResize"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=AutomaticImageResize&amp;action=history"/>
	<updated>2026-08-22T06:15:28Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=AutomaticImageResize&amp;diff=309&amp;oldid=prev</id>
		<title>Admin: 2 revisions imported</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=AutomaticImageResize&amp;diff=309&amp;oldid=prev"/>
		<updated>2016-04-06T20:03:18Z</updated>

		<summary type="html">&lt;p&gt;2 revisions imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This has been tested in [[OmniWeb]], Mozilla, Firefox, and Safari.&lt;br /&gt;
&lt;br /&gt;
Add this javascript function to the javascript section of local/html/Elements/HEADER.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 function resizeImage() {&lt;br /&gt;
        var images = document.getElementsByTagName(&amp;#039;img&amp;#039;);&lt;br /&gt;
        targetWidth = document.body.clientWidth - 250;&lt;br /&gt;
 &lt;br /&gt;
        for (i=0; i &amp;amp;lt; images.length; i++) {&lt;br /&gt;
 &lt;br /&gt;
                if (images[i].width &amp;amp;gt; targetWidth) {&lt;br /&gt;
 &lt;br /&gt;
                        images[i].width = targetWidth;&lt;br /&gt;
                }&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Next add this to the body tag in HEADER&lt;br /&gt;
&lt;br /&gt;
 onResize=&amp;quot;resizeImage()&amp;quot; onLoad=&amp;quot;resizeImage()&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
so that it reads:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;lt;BODY BGCOLOR=&amp;quot;&amp;amp;lt;%$BgColor%&amp;amp;gt;&amp;quot;&lt;br /&gt;
 ONLOAD=&amp;quot;&lt;br /&gt;
 % if ($Focus) {&lt;br /&gt;
    var tmp = (document.getElementsByName(&amp;#039;&amp;amp;lt;% $Focus %&amp;amp;gt;&amp;#039;));&lt;br /&gt;
    if (tmp.length &amp;amp;gt; 0) tmp[tmp.length-1].focus();&lt;br /&gt;
 &lt;br /&gt;
 % }&lt;br /&gt;
 resizeImage();&amp;quot;&lt;br /&gt;
 onResize=&amp;quot;resizeImage()&amp;quot;&lt;br /&gt;
 &amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
(Above example taken from RT 3.2)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The above example didn;t seem to fit v3.8.4 very well, so I came up with this. maybe someone can improve. uses Scriptaculous &amp;quot;Scale&amp;quot; effect, since RT ships with Prototype/Scriptaculous anyway.&lt;br /&gt;
&lt;br /&gt;
Copy html/Elements/[[HeaderJavascript]] to the &amp;quot;local&amp;quot; directory and then edit it to add the following after:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;&amp;amp;lt;%RT-&amp;amp;gt;Config-&amp;amp;gt;Get(&amp;#039;WebPath&amp;#039;)%&amp;amp;gt;/NoAuth/js/scriptaculous/scriptaculous.js?load=effects,controls&amp;quot;&amp;amp;gt;&amp;amp;lt;/script&amp;amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 % if($m-&amp;amp;gt;{&amp;#039;top_path&amp;#039;} =~ /(Display\.html|History\.html)/) { # try to only do this on ticket page&lt;br /&gt;
 &amp;amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;amp;gt;&lt;br /&gt;
 // &amp;amp;lt;![CDATA[&lt;br /&gt;
     Event.observe(window, &amp;#039;load&amp;#039;, function() {&lt;br /&gt;
         var z = $$(&amp;#039;.messagebody img&amp;#039;);&lt;br /&gt;
         var maxImgWidth = document.viewport.getWidth() - 100;&lt;br /&gt;
         z.each(function(n) {&lt;br /&gt;
             if(n.getWidth() &amp;amp;gt; maxImgWidth)&lt;br /&gt;
             {&lt;br /&gt;
                 new Effect.Scale(n, 20, {scaleFromCenter:true} );&lt;br /&gt;
             }&lt;br /&gt;
         });&lt;br /&gt;
     });&lt;br /&gt;
 // ]]&amp;amp;gt;&lt;br /&gt;
 &amp;amp;lt;/script&amp;amp;gt;&lt;br /&gt;
 % }&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The result is that only on Ticket pages, javascript will be added to the page that selects every img inside a messagebody CSS class, checks if it is wider than the viewport, and if so, applies the &amp;quot;Scale&amp;quot; effect to reduce it down to 20% original size.&lt;br /&gt;
&lt;br /&gt;
Doing this will make it so you don&amp;#039;t get scroll bars around images too large to fit in their assigned html area.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>