@param string $media The media query for rules to be appended, e.g. "@media screen and (max-width:639px)",
or an empty string if none.

@return \stdClass Object with properties as described for elements of `$mediaRules`.
330844
private function getOrCreateMediaRuleToAppendTo($media)
    {
        $lastMediaRule = \end($this->mediaRules);
        if ($lastMediaRule !== false && $media === $lastMediaRule->media) {
            return $lastMediaRule;
        }

        $newMediaRule = (object)[
            'media' => $media,
            'ruleBlocks' => [],
        ];
        $this->mediaRules[] = $newMediaRule;
        return $newMediaRule;
    }
600142
public function setMedia($media)
    {
        if (is_string($media)) {
            $this->media = $media;
        } else {
            $msg = "Media must be a string, '" . gettype($media) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
810937
public function setSizeWidthAndHeight(MediaInterface $media)
    {
        $key = $this->originalDir.'/'.$media->getReference();

        $media->setSize($this->filesystemManipulator->size($key));

        if ($media->getType() === $media::IMAGE) {
            $image = $this->imagine->load(
                $this->filesystemManipulator->read($key)
            );
            $size = $image->getSize();
            $media->setWidth($size->getWidth());
            $media->setHeight($size->getHeight());
        }

        return $this;
    }
693369
public function setMedia($media)
	{
		$counter = 0;
		$attachment = $media->getMedia();
		if (is_resource($attachment)) {
			$this->addMultipart("attachment$counter", $attachment);
			$media->setMedia("attach://attachment$counter");
			$counter++;
		}

		$this->media = json_encode($media->toObject());
	}
1096951
public function process(Media $media)
    {
        if ($this->request->getMethod() == 'POST')
        {
            $this->form->handleRequest($this->request);
            if ($this->form->isValid())
            {
                $file = $this->form->get('media')->getData();
                if (!is_null($file))
                {
                    $media->setMediaType($file->getMimeType());
                    $media->setOriginalName($file->getClientOriginalName());
                    $filename = $this->mediaLibraryService->add($file, $media);
                    if ($filename)
                    {
                        // New media
                        if ($media->getId() == 0)
                        {
                            if (is_a($this->user, 'Symfony\Component\Security\Core\User\UserInterface')
                                    && method_exists($this->user, 'getId'))
                            {
                                $media->setOwnerId($this->user->getId());
                            }
                        }
                        else
                        {
                            // We remove old files
                            $this->mediaLibraryService->remove($media);
                        }

                        // We set new file
                        $media->setFullPath($filename);

                        $em = $this->doctrine->getManager();
                        $em->persist($media);
                        $em->flush();
                        return TRUE;
                    }
                }
            }
        }
        return FALSE;
    }
309322
public function getMedia()
    {
        if ($this->media === null) {
            $cache = $this->getMediaCache();

            // Use cached media if possible.
            $cacheKey = md5('media' . $this->getCacheKey());
            if (!$media = $cache->get($cacheKey)) {
                $media = new Media($this->getMediaFolder(), $this->getMediaOrder());
                $cache->set($cacheKey, $media);
            }
            $this->media = $media;
        }

        return $this->media;
    }
600962
public function getMediasAction(Request $request)
    {
        if (!$request->query->has('filters')) {
            return $this->createResponse(array());
        }

        $mediaManager = $this->getMediaManager();

        $filtersKeys = explode(',', $request->query->get('filters'));
        $medias = $mediaManager->findAllByFiltersKeys($filtersKeys);

        return $this->createResponse($medias);
    }
754661
public function supports(&$extensions) {
        $classname = '\media_'.$this->name.'_plugin';
        if (class_exists($classname)) {
            $object = new $classname();
            $result = $object->supports($extensions);
            foreach ($object->get_supported_extensions() as $ext) {
                $extensions[$ext] = $ext;
            }
            return $result;
        }
        return '';
    }
1263505
protected function getRulesContent(array $rules = null, $level = 0)
    {
        if ($level === 0) {
            $rules = $this->getStyleSheet()->getRules();
            $this->errorMessages = [];
        }

        // Get format options
        $options = $this->getOptions($level);

        $content = "";
        foreach ($rules as $rule) {
            if ($options["BaseAddComments"] === true) {
                if (!($rule instanceof CharsetRule)) {
                    $comments = $rule->getComments();
                    foreach ($comments as $comment) {
                        $content .= $options["CommentIntend"] . $comment . $options["CommentLineBreak"];
                    }
                }
            }

            // Skip invalid rules
            if ($rule->getIsValid() === false) {
                // Copy error to the writer
                foreach ($rule->getValidationErrors() as $validationError) {
                    $this->errorMessages[] = $validationError;
                }
                continue;
            }

            if ($rule instanceof CharsetRule) {
                // @charset must be at the beginning of the content
                if ($content === "") {
                    $content .= "@" . ((string)$rule->getVendorPrefix()) . "charset \"" . $rule->getValue() . "\";" . $options["CharsetLineBreak"];
                }
            } elseif ($rule instanceof ImportRule) {
                $content .= $options["BaseIntend"];
                $content .= "@" . ((string)$rule->getVendorPrefix()) . "import ";
                $content .= "url(\"" . Url::escapeUrl($rule->getUrl()) . "\")";

                $mediaQueryConcat = "";
                foreach ($rule->getQueries() as $mediaQuery) {
                    $content .= $mediaQueryConcat;
                    if ($mediaQuery->getIsOnly() === true) {
                        $content .= " only";
                    } else if ($mediaQuery->getIsNot() === true) {
                        $content .= " not";
                    }
                    // Filter default type "all"
                    if ($mediaQuery->getType() !== MediaQuery::TYPE_ALL) {
                        $content .= " " . $mediaQuery->getType();
                    }
                    $conditions = $mediaQuery->getConditions();
                    if (count($conditions) > 0) {
                        if ($mediaQuery->getType() !== MediaQuery::TYPE_ALL) {
                            $content .= " and";
                        }
                        $content .= " (";
                        $mediaConditionConcat = "";
                        foreach ($conditions as $condition) {
                            if ($condition->getIsValid() === true) {
                                $content .= $mediaConditionConcat . $condition->getValue();
                                $mediaConditionConcat = ") and (";
                            } else {
                                // Copy error to the writer
                                foreach ($condition->getValidationErrors() as $validationError) {
                                    $this->errorMessages[] = $validationError;
                                }
                            }
                        }
                        $content .= ")";
                    }
                    $mediaQueryConcat = ",";
                }
                $content .= ";" . $options["ImportLineBreak"];
            } elseif ($rule instanceof NamespaceRule) {
                $content .= $options["BaseIntend"];
                $content .= "@" . ((string)$rule->getVendorPrefix()) . "namespace";
                $prefix = $rule->getPrefix();
                if (!empty($prefix)) {
                    $content .= " " . $prefix;
                }
                $content .= " url(\"" . Url::escapeUrl($rule->getName()) . "\")";
                $content .= ";" . $options["NamespaceLineBreak"];
            } elseif ($rule instanceof DocumentRule) {
                // Prepare rule start content
                $ruleStartContent = $options["BaseIntend"];
                $ruleStartContent .= "@" . ((string)$rule->getVendorPrefix()) . "document";

                // Prepare rule filter content
                $concat = " ";
                $url = $rule->getUrl();
                if (!empty($url)) {
                    $ruleStartContent .= $concat . "url($url)";
                    $concat = $options["DocumentFilterSeparator"];
                }
                $urlPrefix = $rule->getUrlPrefix();
                if (!empty($urlPrefix)) {
                    $ruleStartContent .= $concat . "url-prefix($urlPrefix)";
                    $concat = $options["DocumentFilterSeparator"];
                }
                $domain = $rule->getDomain();
                if (!empty($domain)) {
                    $ruleStartContent .= $concat . "domain($domain)";
                    $concat = $options["DocumentFilterSeparator"];
                }
                $regexp = $rule->getRegexp();
                if (!empty($regexp)) {
                    $ruleStartContent .= $concat . "regexp($regexp)";
                }

                // Prepare rule content
                $ruleRuleContent = $this->getRulesContent($rule->getRules(), $level + 1);

                // Only add the content if valid rules set
                if ($ruleRuleContent !== "") {
                    $content .= $ruleStartContent;
                    $content .= $options["DocumentRuleSetOpen"];
                    $content .= $ruleRuleContent;
                    $content .= $options["DocumentRuleSetClose"];
                } else {
                    $this->errorMessages[] = "Empty document at-rule '$ruleStartContent' ignored.";
                }
            } elseif ($rule instanceof FontFaceRule) {
                // Prepare rule start content
                $ruleStartContent = $options["BaseIntend"];
                $ruleStartContent .= "@" . ((string)$rule->getVendorPrefix()) . "font-face";
                $ruleStartContent .= $options["FontFaceRuleSetOpen"];

                // Prepare rule declarations content
                /** @var FontFaceDeclaration[] $declarations */
                $declarations = $rule->getDeclarations();
                for ($i = 0, $j = count($declarations); $i < $j; $i++) {
                    if ($declarations[$i]->getIsValid() === true) {
                        if ($ruleStartContent !== "") {
                            $content .= $ruleStartContent;
                            $ruleStartContent = "";
                        }
                        if ($options["BaseAddComments"] === true) {
                            $comments = $declarations[$i]->getComments();
                            foreach ($comments as $comment) {
                                $content .= $options["FontFaceRuleSetIntend"] . $comment . $options["FontFaceCommentLineBreak"];
                            }
                        }
                        $content .= $options["FontFaceDeclarationIntend"] . $declarations[$i]->getProperty();
                        $content .= $options["FontFaceDeclarationSeparator"] . $declarations[$i]->getValue();
                        if ($options["BaseLastDeclarationSemicolon"] === true || $i < ($j - 1)) {
                            $content .= ";";
                        }
                        $content .= $options["FontFaceDeclarationLineBreak"];
                    } else {
                        // Copy error to the writer
                        foreach ($declarations[$i]->getValidationErrors() as $validationError) {
                            $this->errorMessages[] = $validationError;
                        }
                    }
                }

                // Only add the content if valid declarations set
                if ($ruleStartContent === "") {
                    $content .= $options["FontFaceRuleSetClose"];
                }
            } elseif ($rule instanceof KeyframesRule) {
                // Prepare rule content
                $ruleStartContent = $options["BaseIntend"];
                $ruleStartContent .= "@" . ((string)$rule->getVendorPrefix()) . "keyframes " ;
                $ruleStartContent .= $rule->getIdentifier();
                $ruleRulesContent = $this->getRulesContent($rule->getRules(), $level + 1);

                // Only add the content if valid rules set
                if ($ruleRulesContent !== "") {
                    $content .= $ruleStartContent;
                    $content .= $options["KeyframesRuleSetOpen"];
                    $content .= $ruleRulesContent;
                    $content .= $options["KeyframesRuleSetClose"];
                } else {
                    $this->errorMessages[] = "Empty keyframes at-rule '$ruleStartContent' ignored.";
                }
            } elseif ($rule instanceof MediaRule) {
                // Prepare rule content
                $ruleStartContent = $options["BaseIntend"];
                $ruleStartContent .= "@" . ((string)$rule->getVendorPrefix()) . "media";
                $mediaQueryConcat = " ";
                $ignoreAllType = true;
                foreach ($rule->getQueries() as $mediaQuery) {
                    $ruleStartContent .= $mediaQueryConcat;
                    if ($mediaQuery->getIsOnly() === true) {
                        $ruleStartContent .= "only ";
                        $ignoreAllType = false;
                    } elseif ($mediaQuery->getIsNot() === true) {
                        $ruleStartContent .= "not ";
                        $ignoreAllType = false;
                    }

                    if ($ignoreAllType === false || $mediaQuery->getType() !== MediaQuery::TYPE_ALL) {
                        $ruleStartContent .= $mediaQuery->getType();
                    }
                    $conditions = $mediaQuery->getConditions();
                    if (count($conditions) > 0) {
                        if ($ignoreAllType === false || $mediaQuery->getType() !== MediaQuery::TYPE_ALL) {
                            $ruleStartContent .= " and ";
                        }
                        $ruleStartContent .= "(";
                        $mediaConditionConcat = "";
                        foreach ($conditions as $condition) {
                            if ($condition->getIsValid() === true) {
                                $ruleStartContent .= $mediaConditionConcat . $condition->getValue();
                                $mediaConditionConcat = ") and (";
                            } else {
                                // Copy error to the writer
                                foreach ($condition->getValidationErrors() as $validationError) {
                                    $this->errorMessages[] = $validationError;
                                }
                            }
                        }
                        $ruleStartContent .= ")";
                    }
                    $mediaQueryConcat = $options["MediaQuerySeparator"];
                    $ignoreAllType = false;
                }
                $ruleRulesContent = $this->getRulesContent($rule->getRules(), $level + 1);

                // Only add the content if valid rules set
                if ($ruleRulesContent !== "") {
                    $content .= $ruleStartContent;
                    $content .= $options["MediaRuleSetOpen"];
                    $content .= $ruleRulesContent;
                    $content .= $options["MediaRuleSetClose"];
                } else {
                    $this->errorMessages[] = "Empty media at-rule '$ruleStartContent' ignored.";
                }
            } elseif ($rule instanceof PageRule) {
                $content .= $options["BaseIntend"];
                $content .= "@" . ((string)$rule->getVendorPrefix()) . "page";

                $selector = $rule->getSelector()->getValue();
                if ($selector !== PageSelector::SELECTOR_ALL) {
                    $content .= " " . $selector;
                }
                $content .= $options["PageRuleSetOpen"];

                /** @var PageDeclaration[] $declarations */
                $declarations = $rule->getDeclarations();
                for ($i = 0, $j = count($declarations); $i < $j; $i++) {
                    if ($declarations[$i]->getIsValid() === true) {
                        if ($options["BaseAddComments"] === true) {
                            $comments = $declarations[$i]->getComments();
                            foreach ($comments as $comment) {
                                $content .= $options["PageDeclarationIntend"] . $comment . $options["PageCommentLineBreak"];
                            }
                        }
                        $content .= $options["PageDeclarationIntend"] . $declarations[$i]->getProperty();
                        $content .= $options["PageDeclarationSeparator"] . $declarations[$i]->getValue();
                        if ($options["BaseLastDeclarationSemicolon"] === true || $i < ($j - 1)) {
                            $content .= ";";
                        }
                        $content .= $options["PageDeclarationLineBreak"];
                    } else {
                        // Copy error to the writer
                        foreach ($declarations[$i]->getValidationErrors() as $validationError) {
                            $this->errorMessages[] = $validationError;
                        }
                    }
                }

                $content .= $options["PageRuleSetClose"];
            } elseif ($rule instanceof SupportsRule) {
                // Prepare rule content
                $ruleStartContent = $options["BaseIntend"];
                $ruleStartContent .= "@" . ((string)$rule->getVendorPrefix()) . "supports ";
                $conditions = $rule->getConditions();
                if (count($conditions) > 0) {
                    $ruleStartContent .= "(";
                    $supportConditionConcat = "";
                    foreach ($conditions as $condition) {
                        if ($condition->getIsValid() === true) {
                            $ruleStartContent .= $supportConditionConcat . $condition->getValue();
                            $supportConditionConcat = ") and (";
                        } else {
                            // Copy error to the writer
                            foreach ($condition->getValidationErrors() as $validationError) {
                                $this->errorMessages[] = $validationError;
                            }
                        }
                    }
                    $ruleStartContent .= ")";
                }
                $ruleRulesContent = $this->getRulesContent($rule->getRules(), $level + 1);

                // Only add the content if valid rules set
                if ($ruleRulesContent !== "") {
                    $content .= $ruleStartContent;
                    $content .= $options["SupportsRuleSetOpen"];
                    $content .= $ruleRulesContent;
                    $content .= $options["SupportsRuleSetClose"];
                } else {
                    $this->errorMessages[] = "Empty supports at-rule '$ruleStartContent' ignored.";
                }
            } elseif ($rule instanceof StyleRuleSet) {
                // Prepare rule content
                $ruleStartContent = $options["BaseIntend"];
                $ruleSelectorContent = "";
                $concat = "";
                foreach ($rule->getSelectors() as $selector) {
                    if ($selector->getIsValid() === true) {
                        $ruleSelectorContent .= $concat . $selector->getValue();
                        $concat = $options["StyleSelectorSeparator"];
                    } else {
                        // Copy error to the writer
                        foreach ($selector->getValidationErrors() as $validationError) {
                            $this->errorMessages[] = $validationError;
                        }
                    }
                }

                // Only add the content if valid selectors set
                if ($ruleSelectorContent !== "") {
                    $ruleStartContent .= $ruleSelectorContent;
                    $ruleStartContent .= $options["StyleDeclarationsOpen"];

                    // Prepare rule declaration content
                    /** @var StyleDeclaration[] $declarations */
                    $ruleDeclarationContent = "";
                    $declarations = $rule->getDeclarations();
                    for ($i = 0, $j = count($declarations); $i < $j; $i++) {
                        if ($declarations[$i]->getIsValid() === true) {
                            if ($options["BaseAddComments"] === true) {
                                $comments = $declarations[$i]->getComments();
                                foreach ($comments as $comment) {
                                    $ruleDeclarationContent .= $options["StyleDeclarationIntend"] . $comment . $options["StyleCommentLineBreak"];
                                }
                            }
                            $important = $declarations[$i]->getIsImportant() ? " !important" : "";
                            $ruleDeclarationContent .= $options["StyleDeclarationIntend"] . $declarations[$i]->getProperty();
                            $ruleDeclarationContent .= $options["StyleDeclarationSeparator"] . $declarations[$i]->getValue() . $important;
                            if ($options["BaseLastDeclarationSemicolon"] === true || $i < ($j - 1)) {
                                $ruleDeclarationContent .= ";";
                            }
                            $ruleDeclarationContent .= $options["StyleDeclarationLineBreak"];
                        } else {
                            // Copy error to the writer
                            foreach ($declarations[$i]->getValidationErrors() as $validationError) {
                                $this->errorMessages[] = $validationError;
                            }
                        }
                    }

                    // Only add the content if valid declarations set
                    if ($ruleDeclarationContent !== "") {
                        $content .= $ruleStartContent;
                        $content .= $ruleDeclarationContent;
                        $content .= $options["StyleDeclarationsClose"];
                    } else {
                        $this->errorMessages[] = "Empty style rule set '$ruleSelectorContent' ignored.";
                    }
                }
            } elseif ($rule instanceof KeyframesRuleSet) {
                // Prepare rule content
                $ruleStartContent = $options["BaseIntend"];
                $ruleSelectorContent = "";
                $concat = "";
                foreach ($rule->getKeyframes() as $keyframe) {
                    if ($keyframe->getIsValid() === true) {
                        $ruleSelectorContent .= $concat . $keyframe->getValue();
                        $concat = $options["KeyframesSelectorSeparator"];
                    } else {
                        // Copy error to the writer
                        foreach ($keyframe->getValidationErrors() as $validationError) {
                            $this->errorMessages[] = $validationError;
                        }
                    }
                }

                // Only add the content if valid selectors set
                if ($ruleSelectorContent !== "") {
                    $ruleStartContent .= $ruleSelectorContent;
                    $ruleStartContent .= $options["KeyframesDeclarationsOpen"];

                    /** @var KeyframesDeclaration[] $declarations */
                    $ruleDeclarationContent = "";
                    $declarations = $rule->getDeclarations();
                    for ($i = 0, $j = count($declarations); $i < $j; $i++) {
                        if ($declarations[$i]->getIsValid() === true) {
                            $ruleDeclarationContent .= $options["KeyframesDeclarationIntend"] . $declarations[$i]->getProperty();
                            $ruleDeclarationContent .= $options["KeyframesDeclarationSeparator"] . $declarations[$i]->getValue();
                            if ($options["BaseLastDeclarationSemicolon"] === true || $i < ($j - 1)) {
                                $ruleDeclarationContent .= ";";
                            }
                            $ruleDeclarationContent .= $options["KeyframesDeclarationLineBreak"];
                        } else {
                            // Copy error to the writer
                            foreach ($declarations[$i]->getValidationErrors() as $validationError) {
                                $this->errorMessages[] = $validationError;
                            }
                        }
                    }

                    // Only add the content if valid declarations set
                    if ($ruleDeclarationContent !== "") {
                        $content .= $ruleStartContent;
                        $content .= $ruleDeclarationContent;
                        $content .= $options["KeyframesDeclarationsClose"];
                    } else {
                        $this->errorMessages[] = "Empty keyframes rule set '$ruleSelectorContent' ignored.";
                    }
                }
            }
        }

        // Save complete style sheet content in property
        if ($level === 0) {
            $this->content = $content;
        }

        return $content;
    }
66377
public function prepareMedia(Media $media)
    {
        if (null === $media->getUuid()) {
            $uuid = uniqid();
            $media->setUuid($uuid);
        }
        $content = $media->getContent();
        if (empty($content)) {
            return;
        }
        if (!$content instanceof File) {
            if (!is_file($content)) {
                throw new \RuntimeException('Invalid file');
            }
            $file = new File($content);
            $media->setContent($file);
        }
        if ($content instanceof UploadedFile) {
            $pathInfo = pathinfo($content->getClientOriginalName());
            $media->setOriginalFilename($this->urlizer->urlize($pathInfo['filename']).'.'.$pathInfo['extension']);
            $name = $media->getName();
            if (empty($name)) {
                $media->setName($media->getOriginalFilename());
            }
        }
        $media->setFileSize(filesize($media->getContent()));
        $contentType = $this->mimeTypeGuesser->guess($media->getContent()->getPathname());
        $media->setContentType($contentType);
        $relativePath = sprintf('/%s.%s', $media->getUuid(), ExtensionGuesser::getInstance()->guess($media->getContentType()));
        $media->setUrl('/uploads/media'.$relativePath);
        $media->setLocation('local');
    }
284168
public function checkForDuplicate($media)
    {
        $duplicate = $this->getModelManager()->findOneBy(
            $this->getClass(),
            [
                'context' => $media->getContext(),
                'md5File' => $media->getMd5File(),
            ]
        );

        return $duplicate;
    }
1310635
public function path($media, $format)
    {
        if (!$media) {
            return '';
        }

        $provider = $this->getProvider($media);

        $format = $provider->getFormatName($media, $format);

        return $provider->generatePublicUrl($media, $format);
    }
165713
protected function _getRule($rule)
    {
        if ($rule instanceof FilterInterface) {
            return $rule;
        }

        $rule = (string) $rule;
        return $this->getPluginManager()->get($rule);
    }
283537
public function getCoverImage()
    {
        if ($this->getValueSet() !== null) {
            foreach ($this->getValueSet()->getValues() as $value) {
                if ($value instanceof MediaValue &&
                    false !== $media = $value->getMedias()->first()) {
                    return $media->getReference();
                }
            }
        }

        foreach ($this->getBlocks() as $block) {
            $reflect = new \ReflectionClass($block);

            if ($reflect->hasProperty('media') && $block->getMedia()) {
                return $block->getMedia()->getReference();
            }
        }

        return false;
    }
1021889
public function prepareMedia(Media $media)
    {
        if (null == $media->getUuid()) {
            $uuid = uniqid();
            $media->setUuid($uuid);
        }
        $video = new RemoteVideoHelper($media);
        $url = $video->getCode();
        //update thumbnail
        switch ($video->getType()) {
            case 'youtube':
                $code = $this->isolateYoutubeVideoCode($url);
                $video->setThumbnailUrl('http://img.youtube.com/vi/'.$code.'/0.jpg');
                break;
            case 'vimeo':
                $code = $this->isolateVimeoVideoCode($url);
                $xml = simplexml_load_file('http://vimeo.com/api/v2/video/'.$code.'.xml');
                $video->setThumbnailUrl((string) $xml->video->thumbnail_large);
                break;
            case 'dailymotion':
                $code = $this->isolateDailymotionVideoCode($url);
                $json = json_decode(file_get_contents('https://api.dailymotion.com/video/'.$code.'?fields=thumbnail_large_url'));
                $thumbnailUrl = $json->{'thumbnail_large_url'};
                /* dirty hack to fix urls for imagine */
                if (!$this->endsWith($thumbnailUrl, '.jpg') && !$this->endsWith($thumbnailUrl, '.png')) {
                    $thumbnailUrl = $thumbnailUrl.'&ext=.jpg';
                }
                $video->setThumbnailUrl($thumbnailUrl);
                break;
        }
    }
744706
public function search($params)
    {
        $query = Media::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'file_size' => $this->file_size,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
            'created_by' => $this->created_by,
            'updated_by' => $this->updated_by,
        ]);

        $query->andFilterWhere(['like', 'name', $this->name])
            ->andFilterWhere(['like', 'path', $this->path])
            ->andFilterWhere(['like', 'title', $this->title])
            ->andFilterWhere(['like', 'caption', $this->caption])
            ->andFilterWhere(['like', 'alt', $this->alt])
            ->andFilterWhere(['like', 'description', $this->description])
            ->andFilterWhere(['like', 'dimensions', $this->dimensions])
            ->andFilterWhere(['like', 'type', $this->type])
            ->andFilterWhere(['like', 'status', $this->status]);

        return $dataProvider;
    }
1058608
public function format($format = null)
    {
        $media = $this->_classes['media'];

        if (!func_num_args()) {
            if ($this->_format === null) {
                $this->_format = $media::suitable($this);
            }
            return $this->_format;
        }
        if ($format === null) {
            return $this;
        }

        if (!$mime = $media::mime($format)){
            throw new NetException("The `'{$format}'` format is undefined or has no valid Content-Type defined check the `Media` class.");
        }
        $this->_format = $format;
        $this->mime($mime);

        return $this;
    }