modifier.image_format.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 
12 /**
13  * Output the format ('portrait' or 'landscape') of the given image
14  *
15  * Example:
16  * @code
17  * <img src="{$image}" class="{$image|image_format}">
18  * @endcode
19  *
20  * @param $image The path to the image
21  * @return String
22  */
23 function smarty_modifier_image_format($image) {
24  if (strlen($image) > 0 && file_exists($image)) {
25  $size = getimagesize($image);
26  if ($size !== false) {
27  return $size[0] > $size[1] ? 'landscape' : 'portrait';
28  }
29  }
30  return '';
31 }
32 ?>