Bonjour,
J'ai un code affichant la première image d'une page:
J'aimerais, dans ce code, pouvoir changer tout les nom des images (présentement c'est *-188x145.* et j'aimerais faire disparaitre le -188x145).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 function that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = "/images/default.jpg"; } return $first_img; } echo that_image();
Merci
Partager