<?php


$function = new Twig_SimpleFunction('imagesize', function ($fileName) {

  $documentRoot = trim(getcwd(), "pattern-lab") . '/source';
  
  
  $newfileName = str_replace('/images', 'images', $fileName);
  
  $filePath = $documentRoot . $newfileName;
  
  
  if (file_exists($filePath)){
    $size = getimagesize($filePath);
  
    return ($size[0]);
  }
    
});
