public function srcset($images, $descriptor = 'w'): string
    {
        $r = '';
        $generated = [];

        if (!\is_array($images)) {
            return '';
        }

        foreach ($images as $image) {
            switch ($descriptor) {
                case 'w':
                    if (!isset($generated[$image->getWidth()])) {
                        $r .= $image->getUrl().' '.$image->getWidth().'w, ';
                        $generated[$image->getWidth()] = true;
                    }
                    break;
                case 'h':
                    if (!isset($generated[$image->getHeight()])) {
                        $r .= $image->getUrl().' '.$image->getHeight().'h, ';
                        $generated[$image->getHeight()] = true;
                    }
                    break;
                case 'w+h':
                    $key = $image->getWidth().'x'.$image->getHeight();
                    if (!isset($generated[$key])) {
                        $r .= $image->getUrl().' '.$image->getWidth().'w '.$image->getHeight().'h, ';
                        $generated[$image->getWidth().'x'.$image->getHeight()] = true;
                    }
                    break;
            }
        }

        return $r !== '' ? substr($r, 0, -2) : '';
    }
public function srcset($images, $descriptor = 'w'): string
    {
        $r = '';
        $generated = [];

        if (!\is_array($images)) {
            return '';
        }

        foreach ($images as $image) {
            switch ($descriptor) {
                case 'w':
                    if (!isset($generated[$image->getWidth()])) {
                        $r .= $image->getUrl().' '.$image->getWidth().'w, ';
                        $generated[$image->getWidth()] = true;
                    }
                    break;
                case 'h':
                    if (!isset($generated[$image->getHeight()])) {
                        $r .= $image->getUrl().' '.$image->getHeight().'h, ';
                        $generated[$image->getHeight()] = true;
                    }
                    break;
                case 'w+h':
                    $key = $image->getWidth().'x'.$image->getHeight();
                    if (!isset($generated[$key])) {
                        $r .= $image->getUrl().' '.$image->getWidth().'w '.$image->getHeight().'h, ';
                        $generated[$image->getWidth().'x'.$image->getHeight()] = true;
                    }
                    break;
            }
        }

        return $r !== '' ? substr($r, 0, -2) : '';
    }
public function srcset ( $ images , $ descriptor = 'w' ) : string { $ r = '' ; $ generated = [ ] ; if ( ! \ is_array ( $ images ) ) { return '' ; } foreach ( $ images as $ image ) { switch ( $ descriptor ) { case 'w' : if ( ! isset ( $ generated [ $ image -> getWidth ( ) ] ) ) { $ r .= $ image -> getUrl ( ) . ' ' . $ image -> getWidth ( ) . 'w, ' ; $ generated [ $ image -> getWidth ( ) ] = true ; } break ; case 'h' : if ( ! isset ( $ generated [ $ image -> getHeight ( ) ] ) ) { $ r .= $ image -> getUrl ( ) . ' ' . $ image -> getHeight ( ) . 'h, ' ; $ generated [ $ image -> getHeight ( ) ] = true ; } break ; case 'w+h' : $ key = $ image -> getWidth ( ) . 'x' . $ image -> getHeight ( ) ; if ( ! isset ( $ generated [ $ key ] ) ) { $ r .= $ image -> getUrl ( ) . ' ' . $ image -> getWidth ( ) . 'w ' . $ image -> getHeight ( ) . 'h, ' ; $ generated [ $ image -> getWidth ( ) . 'x' . $ image -> getHeight ( ) ] = true ; } break ; } } return $ r !== '' ? substr ( $ r , 0 , - 2 ) : '' ; }
Creates srcset string

@param array|mixed  $images
@param string $descriptor

@return string
Creates srcset string