imgsize in upload.php

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

imgsize in upload.php

Dion Almaer

Hi guys,

A small thing, but I always like my authors to put full height/width on
images that they upload, so I quickly hacked upload.php (in my blog platform
on WP 1.5, soon to be 2.0) to have:

---
if ( ereg('image/',$img1_type) ) {
        list($width, $height, $type, $attr) =
getimagesize(get_settings('fileupload_realpath') . '/' . $img1_name);

        $piece_of_code = '<img src="' . get_settings('fileupload_url') .'/'
. $img1_name . '" alt="' . $imgdesc . '" border="0" ' . $attr . '/>'; } else
{
        $piece_of_code = "<a href='". get_settings('fileupload_url') .
"/$img1_name' title='$imgdesc'>$imgdesc</a>"; }

$piece_of_code = htmlspecialchars( $piece_of_code );
---

In general I try hard not to change any of the core files and use plugins
and hooks to make all changes. This was one that I had to make to the core,
so thought if people would prefer it... Maybe we could have it in there? :)

Cheers,

Dion Almaer
Founder, Ajaxian.com
http://ajaxian.com
Cleaning up the web with Ajax
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: imgsize in upload.php

Craig-16
My comment to this is wondering about the border="0" declaration. Would that
override any CSS styling created by the active site theme? I would offer the
opinion that styling should be in the CSS file(s) and not the code itself.

Craig.
Nuclear Moose.
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: imgsize in upload.php

Dion Almaer
Craig,

You are right about the border="0" for the generic case.

It was pragmatic in my situation.

I care more about the width/height being put in programatically.

Cheers,

Dion
 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Craig
> Sent: Wednesday, February 08, 2006 3:38 PM
> To: [hidden email]
> Subject: Re: [wp-hackers] imgsize in upload.php
>
> My comment to this is wondering about the border="0"
> declaration. Would that override any CSS styling created by
> the active site theme? I would offer the opinion that styling
> should be in the CSS file(s) and not the code itself.
>
> Craig.
> Nuclear Moose.
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: imgsize in upload.php

Abhay Kumar
Could someone clarify why we wouldn't want some backend php code [e.g.
imagesx($img), imagesy($img)], to calculate the images parameters? Is
it becuase we don't want to depend upon php_gd?

Also, I could understand why one would want to define the image's
dimensions (or maybe the width dimension/relative size) for the image
to appear correctly within a post, but the full height and width? I
don't see the purpose. Perhaps I'm being shortsighted.

Abhay

On 2/8/06, Dion Almaer <[hidden email]> wrote:

> Craig,
>
> You are right about the border="0" for the generic case.
>
> It was pragmatic in my situation.
>
> I care more about the width/height being put in programatically.
>
> Cheers,
>
> Dion
>
>
> > -----Original Message-----
> > From: [hidden email]
> > [mailto:[hidden email]] On Behalf Of Craig
> > Sent: Wednesday, February 08, 2006 3:38 PM
> > To: [hidden email]
> > Subject: Re: [wp-hackers] imgsize in upload.php
> >
> > My comment to this is wondering about the border="0"
> > declaration. Would that override any CSS styling created by
> > the active site theme? I would offer the opinion that styling
> > should be in the CSS file(s) and not the code itself.
> >
> > Craig.
> > Nuclear Moose.
> > _______________________________________________
> > wp-hackers mailing list
> > [hidden email]
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


--
Abhay Kumar
http://abhaykumar.net/
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: imgsize in upload.php

Andy Skelton
On 2/9/06, Abhay Kumar <[hidden email]> wrote:
> Also, I could understand why one would want to define the image's
> dimensions (or maybe the width dimension/relative size) for the image
> to appear correctly within a post, but the full height and width? I
> don't see the purpose. Perhaps I'm being shortsighted.

If the image fails to load, its absence will cause the surrounding
text etc. to flow differently. Sometimes that's bad. The effect can be
avoided by specifying the height and width attributes.

Andy
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: imgsize in upload.php

Dion Almaer

Exactly.

I always want to tell the browser the space it needs to allocate for all
elements. This is a nice thing to do for the poor old browser, as then he
doesn't have to keep rerendering and guessing (and as Andy says, if the
image doesn't download correctly... Who knows).

This is just the default. You obviously can change the height/width/anything
else that you want.  I just prefer this as a default.

Cheers,

Dion
 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Andy Skelton
> Sent: Thursday, February 09, 2006 2:33 PM
> To: [hidden email]
> Subject: Re: [wp-hackers] imgsize in upload.php
>
> On 2/9/06, Abhay Kumar <[hidden email]> wrote:
> > Also, I could understand why one would want to define the image's
> > dimensions (or maybe the width dimension/relative size) for
> the image
> > to appear correctly within a post, but the full height and width? I
> > don't see the purpose. Perhaps I'm being shortsighted.
>
> If the image fails to load, its absence will cause the
> surrounding text etc. to flow differently. Sometimes that's
> bad. The effect can be avoided by specifying the height and
> width attributes.
>
> Andy
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...