Created
December 29, 2019 17:47
-
-
Save ChristopherDosin/95cd3c43b82fad750aefa1e4e339ffa8 to your computer and use it in GitHub Desktop.
Shopware Media Modifier Smarty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function smarty_modifier_mediaurl($value, $format = array()) | |
{ | |
if (is_numeric($value)) { | |
$id = (int)$value; | |
$media = Shopware()->Models()->getRepository('Shopware\Models\Media\Media')->findOneBy(['id' => $id]); | |
if ($media) { | |
$path = $media->getPath(); | |
$mediaUrl = Shopware()->Container()->get('shopware_media.media_service')->getUrl($path); | |
return $mediaUrl; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment