diff options
Diffstat (limited to 'model')
| -rw-r--r-- | model/Article.php | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/model/Article.php b/model/Article.php index 24480ed..d0fb019 100644 --- a/model/Article.php +++ b/model/Article.php | |||
| @@ -50,13 +50,12 @@ class Article | |||
| 50 | 50 | ||
| 51 | private function makeHtmlMiniImages($content) | 51 | private function makeHtmlMiniImages($content) |
| 52 | { | 52 | { |
| 53 | while(preg_match('#<img src=.+/images/.+>#', $content)) | 53 | // insérer -mini au nom du dossier et au fichier |
| 54 | { | 54 | // on choisit pour bien faire de cibler toute la balise <img/> |
| 55 | // ? => mode paresseux, on fait matcher le moins d'occurences possibles | 55 | $pattern = array('#(<img[^>]+/images(?!-mini))([^>]+>)#', |
| 56 | $pattern = '#(<img src=.+/)(images)(/.+?)(\.jpg|\.jpeg|\.png|\.gif.+>)#'; | 56 | '#(<img[^>]+)((?<!-mini)(\.jpg|\.jpeg|\.png|\.gif)[^>]+>)#'); |
| 57 | // insérer -mini au nom du dossier et au fichier | 57 | $remplacement = array('$1-mini$2', '$1-mini$2'); |
| 58 | $content = preg_replace($pattern, '$1$2-mini$3-mini$4', $content); | 58 | $content = preg_replace($pattern, $remplacement, $content); |
| 59 | } | ||
| 60 | 59 | ||
| 61 | return $content; | 60 | return $content; |
| 62 | } | 61 | } |
