Automattic / Automattic/VIP-Coding-Standards

Sniff for getimagesize()

Abierto
#685 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
PHP
Estrellas
261
Forks
44
Merge medio
19 min
PR fusionados (30 d)
1

Descripción

## 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.
```

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
php
Área
tooling
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.