Bonjour,
j'utilise une fonction pour retirer tout ce qui se trouve dans <img sauf Src=, mais alt="" quand est vide il n'est pas supprimer et aussi srcset il est bien supprimé mais pas ce qu'il y a à l’intérieur ou plutôt il ne supprimait que 4 caractères, je sais pas ou est mon erreur.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
$srt = '<table>
<tbody>
<tr>
<td><img class="aligncenter wp-image-4359 size-full" src="http://www.unesourisetmoi.info/data/medias/0240/fond-ecran-tablette.jpg" alt="" width="534" height="420" srcset="http://www.unesourisetmoi.info/data/medias/0240/fond-ecran-tablette.jpg 534w, http://www.unesourisetmoi.info/data/medias/photos/240/changer-fond-ecran-tablette_2.jpg 300w" sizes="(max-width: 534px) 100vw, 534px" /></td>
<td>
<p><figure id="attachment_4350" style="max-width: 389px" class="wp-caption aligncenter"><img class="wp-image-4350 size-full" src="http://www.unesourisetmoi.info/data/medias/photos/240/changer-fond-ecran-tablette_1.jpg" alt="" width="389" height="276" srcset="http://www.unesourisetmoi.info/data/medias/photos/240/changer-fond-ecran-tablette_1.jpg 389w, http://www.unesourisetmoi.info/data/medias/photos/240/changer-fond-ecran-tablette_3.jpg 300w" sizes="(max-width: 389px) 100vw, 389px" /><figcaption class="wp-caption-text">Aperçu sur </figcaption></figure></td>
</tr>
</tbody>
</table>';
Code : Sélectionner tout - Visualiser dans une fenêtre à part
echo  sky_cleanup_attributes($srt);
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
function sky_cleanup_attributes($source)
{
    $remove = array('srcset', 'style', 'class', 'alt', 'style', 'itemprop', 'width', 'height', 'sizes');
    $cleanstring = $source;
    foreach($remove as $attribute)
    {
        $cleanstring = preg_replace('!\s+'.$attribute.'=("|\')?[-_():;a-z0-9 ]+("|\')?!i','',$cleanstring);
    }
    return $cleanstring;
}
merci a tous