Skip to content

Drop getimagesize()[3] (width and height for img) #17707

Open
@cmb69

Description

@cmb69

Description

From the getimagesize() docs:

Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag.

Besides that this is not really a convenience feature, it may easily give outright wrong information, since e.g. the EXIF Orientation tag is ignored. To wit:

Image

php > var_dump(getimagesize("../bar.jpg")[3]);
string(23) "width="100" height="10""

Using these dimension actually defeats the whole point of using these attributes (namely to inform the browser of the expected dimensions upfront for layout purposes).

I suggest to drop this index from the return value. While that is clearly a BC break (and cannot be mitigated by a deprecation), it is not that bad, since index 3 is the last numerical index; further elements have string keys.

PS: a less drastic measure could be to just provide an empty string. That is less likely to break existing code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions