Question: `$image` variable gives this code (when `echo` is used):

```
<img src="/image.png" width="100" height="147" alt="" class="some_class" />

```

* `width`, `height`, `src` and `class` 
attributes can be different.

What should we do:

1. **remove** `width` and `height` from `$image`
2. replace `alt=""` with `alt="Poster"`

Thanks.

Answer: 
```
$pattern = '/alt="" width="\d+" height="\d+"/i';
$replacement = 'alt="Poster"';
$variable = preg_replace($pattern, $replacement, $variable);

```

fix to work with any order of attributes(Gordon's comment):

```
$pattern = '/alt=""/i';
$replacement = 'alt="Poster"';
$variable = preg_replace($pattern, $replacement, $variable);
$pattern = '/width="\d+"/i';
$replacement = '';
$variable = preg_replace($pattern, $replacement, $variable);
$pattern = '/height="\d+"/i';
$replacement = '';
$variable = preg_replace($pattern, $replacement, $variable);

```
will also replace `<embed width="x">` which is wrong. We need to catch only with `<img>` tag