PHP warning

Invalid argument supplied for foreach()

/srv/users/major-tom/apps/major-tom/craft/plugins/imager/variables/ImagerVariable.php(45)

33      *
34      * todo : Implement support for other descriptors
35      *
36      * @param Array $images
37      * @param string $descriptor
38      * @return string
39      */
40     public function srcset($images, $descriptor = 'w')
41     {
42         $r = '';
43         $widths = array();
44 
45         foreach ($images as $image) {
46             if (!isset($widths[$image->getWidth()])) {
47                 $r .= $image->getUrl() . ' ' . $image->getWidth() . 'w, ';
48                 $widths[$image->getWidth()] = true;
49             }
50         }
51 
52         return substr($r, 0, strlen($r) - 2);
53     }
54 
55     /**
56      * Returns a base64 encoded transparent pixel. Useful for adding as src on img tags for validation when using srcset.
57      * 

Stack Trace

#0
+
 /srv/users/major-tom/apps/major-tom/craft/app/etc/web/WebApp.php(694): CApplication->handleError(2, "Invalid argument supplied for foreach()", "/srv/users/major-tom/apps/major-tom/craft/plugins/imager/variabl...", 45)
689         if (version_compare(PHP_VERSION, '7.1', '>=') && strpos($message, 'Narrowing occurred during type inference. Please file a bug report') !== false)
690         {
691             return;
692         }
693 
694         parent::handleError($code, $message, $file, $line);
695     }
696 
697     /**
698      * Raised right AFTER the application processes the request.
699      *
#1
+
 /srv/users/major-tom/apps/major-tom/craft/plugins/imager/variables/ImagerVariable.php(45): Craft\WebApp->handleError(2, "Invalid argument supplied for foreach()", "/srv/users/major-tom/apps/major-tom/craft/plugins/imager/variabl...", 45, ...)
40     public function srcset($images, $descriptor = 'w')
41     {
42         $r = '';
43         $widths = array();
44 
45         foreach ($images as $image) {
46             if (!isset($widths[$image->getWidth()])) {
47                 $r .= $image->getUrl() . ' ' . $image->getWidth() . 'w, ';
48                 $widths[$image->getWidth()] = true;
49             }
50         }
#2
+
 /srv/users/major-tom/apps/major-tom/craft/app/vendor/twig/twig/src/Template.php(685): Craft\ImagerVariable->srcset(null)
680         // to call is not supported. If ignoreStrictCheck is true, we should return null.
681         try {
682             if (!$arguments) {
683                 $ret = $object->$method();
684             } else {
685                 $ret = \call_user_func_array([$object, $method], $arguments);
686             }
687         } catch (\BadMethodCallException $e) {
688             if ($call && ($ignoreStrictCheck || !$this->env->isStrictVariables())) {
689                 return;
690             }
2024-03-28 11:23:25 Apache/2.4.58 (Unix) OpenSSL/1.1.1 / Craft CMS 2.7.8