Automattic / Automattic/VIP-Coding-Standards

Sniff for getimagesize()

Đang mở
#685 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
PHP
Star
261
Fork
44
Merge trung bình
19 phút
Pull request đã merge (30 ngày)
1

Mô tả

## What problem would the enhancement address for VIP?

`getimagesize()` holds up the PHP process downloading the entire image to just read its file size.

## Describe the solution you'd like

Most images in WPs Media Library have width and height attributes already (like from `wp_get_attachment_metadata()`) & that existing data should be used instead.

If the image is external and not in WordPress' media library, perhapes:
* a VIP helper function could be created [to download only first few bytes of image](https://www.php.net/manual/en/function.getimagesize.php#88793)
* don't use this function, or do image sizing w/ JS or CSS instead

## What code should be reported as a violation?

```php
$size = getimagesize( $image_url );
list($width, $height) = getimagesize( $image_url );
//etc.
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start with the getimagesize() violation examples and the proposed wp_get_attachment_metadata() path, then review how the ruleset identifies PHP function calls. Clarify the expected handling for Media Library images versus external URLs before defining completion and adding coverage for both cases.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
php
Lĩnh vực
tooling
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.