Skip to content

Instantly share code, notes, and snippets.

@ChristopherDosin
Created December 29, 2019 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChristopherDosin/95cd3c43b82fad750aefa1e4e339ffa8 to your computer and use it in GitHub Desktop.
Save ChristopherDosin/95cd3c43b82fad750aefa1e4e339ffa8 to your computer and use it in GitHub Desktop.
Shopware Media Modifier Smarty
<?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