Craft\MinimeeTwigExtension::minimeeFilter PHP Method

minimeeFilter() public method

Define our filter
public minimeeFilter ( String $html, Array $settings = [] ) : String
$html String
$settings Array
return String
    public function minimeeFilter($html, $settings = array())
    {
        // we need a type to continue
        $type = $this->detectType($html);
        if (!$type) {
            MinimeePlugin::log('Could not determine the type of asset to process.', LogLevel::Warning);
            return minimee()->service->makeTwigMarkupFromHtml($html);
        }
        // we need to find some assets in the HTML
        $assets = $this->pregMatchAssetsByType($type, $html);
        if (!$assets) {
            MinimeePlugin::log('No assets of type ' . $type . ' could be found.', LogLevel::Warning);
            return minimee()->service->makeTwigMarkupFromHtml($html);
        }
        // hand off the rest to our service
        $minified = minimee()->service->run($type, $assets, $settings);
        // false means we failed, so return original markup
        if (!$minified) {
            return minimee()->service->makeTwigMarkupFromHtml($html);
        }
        $minifiedAsTags = minimee()->service->makeTagsByType($type, $minified);
        // return minified tag(s) as Twig Markup
        return minimee()->service->makeTwigMarkupFromHtml($minifiedAsTags);
    }