I have created a blogging system where users can upload pics to their
galleries then place them into their blogs by way of <img> tags. The problem
is, when the image is over 550 pixels in width, it blows up the tables in
the website. I have already warned them not to put huge images in the blogs
and have limited the filesize, but there is no way to stop people. Even
posting this warning it in bright red, super large text does not seem to put
a dent it in.
Is there a way to limit the width of an uploaded image?
If not, is there a way to scan for image tags with width greater than 550
and then replace the width attribute?
Noël® - 31 Oct 2005 17:27 GMT
>I have created a blogging system where users can upload pics to their
>galleries then place them into their blogs by way of <img> tags. The
[quoted text clipped - 8 lines]
> If not, is there a way to scan for image tags with width greater than 550
> and then replace the width attribute?
Something like this: (you might will need to set the:
#ExpandPath('#ServerFile#')# )
<!--- :: Get image width and height --->
<cfobject type="JAVA" action="Create" name="tk" class="java.awt.Toolkit">
<cfobject type="JAVA" action="Create" name="img" class="java.awt.Image">
<cfscript>
img = tk.getDefaultToolkit().getImage("#ExpandPath('#ServerFile#')#");
Width = img.getWidth();
Height = img.getHeight();
</cfscript>
<!--- :: Get image width and height :: --->
<cfif Width GT 550>
no no Width is to much!
<cffile action = "delete" file = "#ExpandPath('#ServerFile#')#">
</cfif>
<cfif Height GT 550>
no no Height is to much!
<cffile action = "delete" file = "#ExpandPath('#ServerFile#')#">
</cfif>