| Conditions | 6 |
| Paths | 6 |
| Total Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | protected function inlineImage($excerpt) |
||
| 28 | { |
||
| 29 | $image = parent::inlineImage($excerpt); |
||
| 30 | |||
| 31 | if (!isset($image)) { |
||
| 32 | return null; |
||
| 33 | } |
||
| 34 | |||
| 35 | preg_match( |
||
| 36 | '/'.self::PATTERN.'/s', |
||
| 37 | $image['element']['attributes']['src'], |
||
| 38 | $matches |
||
| 39 | ); |
||
| 40 | |||
| 41 | if (!$matches) { |
||
| 42 | return $image; |
||
| 43 | } |
||
| 44 | |||
| 45 | if (key_exists(3, $matches) && $matches[3] == 'resize') { |
||
| 46 | $image['element']['attributes']['src'] = $matches[1]; |
||
| 47 | $resize = $matches[4]; |
||
| 48 | } |
||
| 49 | |||
| 50 | if ($this->config === null) { |
||
| 51 | return $image; |
||
| 52 | } |
||
| 53 | |||
| 54 | Util::getFS()->mkdir($this->config->getOutputPath().'/assets'); |
||
| 55 | |||
| 56 | Image::make($this->config->getStaticPath().'/'.$image['element']['attributes']['src']) |
||
| 57 | ->resize($resize, null, function ($constraint) { |
||
| 58 | $constraint->aspectRatio(); |
||
| 59 | $constraint->upsize(); |
||
| 60 | }) |
||
| 61 | ->save($this->config->getOutputPath(). '/assets'.$image['element']['attributes']['src']); |
||
| 62 | |||
| 63 | $image['element']['attributes']['src'] = '/assets'.$image['element']['attributes']['src']; |
||
| 64 | |||
| 65 | return $image; |
||
| 66 | } |
||
| 67 | } |
||
| 68 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.