function getFilteredMedia(array $filters, $allowPlaceholder = true)
    {
        $col = [];
        foreach($this['media'] as $medium) {
            if (!isset($hasImage) && $medium['type'] == 'image') {
                $hasImage = true;
            }
            if (in_array($medium['type'], $filters)) {
                $col[] = $medium;
            }
        }

        // Add a placeholder if the image type was requested, and no images were found.
        if (in_array('image', $filters)
            && !isset($hasImage)
            && $allowPlaceholder
            && $this->getPlaceholder()) {
            $col[] = $this->getPlaceholder();
        }

        return $col;
    }
function getFilteredMedia(array $filters, $allowPlaceholder = true)
    {
        $col = [];
        foreach($this['media'] as $medium) {
            if (!isset($hasImage) && $medium['type'] == 'image') {
                $hasImage = true;
            }
            if (in_array($medium['type'], $filters)) {
                $col[] = $medium;
            }
        }

        // Add a placeholder if the image type was requested, and no images were found.
        if (in_array('image', $filters)
            && !isset($hasImage)
            && $allowPlaceholder
            && $this->getPlaceholder()) {
            $col[] = $this->getPlaceholder();
        }

        return $col;
    }
function getFilteredMedia ( array $ filters , $ allowPlaceholder = true ) { $ col = [ ] ; foreach ( $ this [ 'media' ] as $ medium ) { if ( ! isset ( $ hasImage ) && $ medium [ 'type' ] == 'image' ) { $ hasImage = true ; } if ( in_array ( $ medium [ 'type' ] , $ filters ) ) { $ col [ ] = $ medium ; } } // Add a placeholder if the image type was requested, and no images were found. if ( in_array ( 'image' , $ filters ) && ! isset ( $ hasImage ) && $ allowPlaceholder && $ this -> getPlaceholder ( ) ) { $ col [ ] = $ this -> getPlaceholder ( ) ; } return $ col ; }
Filter media by types

@param array $filters    image|video|document|audio|other(binary attachments)
Filter media by types