function image_tag($src, $alt = NULL, array $attrs = array()) { if (is_array($alt)) { $attrs = $alt; $alt = $src; } if (!$alt or $alt === $src) { $ext = \IO\File::ext($src, TRUE); $alt = titlecase(basename($src, $ext)); } $attrs['alt'] = $attrs['title'] = $alt; try { $img = \Tailor\Helpers::image($src); $attrs['width'] = $img['dims'][0]; $attrs['height'] = $img['dims'][1]; $attrs['src'] = asset_url($src); } catch (\Exception $e) { $attrs['src'] = $src; } return \Labourer\Web\Html::tag('img', $attrs); }
if (!isset($cache[$key])) { if (s3_handle()) { s3_upload_asset($old, $key); } elseif (!is_file($new)) { is_dir(dirname($new)) or mkdir(dirname($new), 0777, TRUE); copy($old, $new); } $cache[$key] = 1; status('prepare', $key); } } } // asset mashup, grouped if (!empty($tmp['include'])) { foreach ($tmp['include'] as $test) { $ext = \IO\File::ext($test); $key = str_replace(APP_PATH . DIRECTORY_SEPARATOR, '', $test); $name = join('.', array_slice(explode('.', basename($test)), 0, 2)); $path = str_replace(path(APP_PATH, 'app', 'assets', $type), '__', dirname($test)); if ($ext != $type) { $cache_file = path($cache_dir, strtr("{$path}/{$name}", '\\/', '__')); if (is_file($cache_file)) { $out[$key] = !empty($cache[$key]) ? $cache[$key] : ($cache[$key] = read($cache_file)); } else { if (!empty($cache[$key])) { $out[$key] = $cache[$key]; } else { $out[$key] = \Tailor\Base::compile($test); write($cache_file, $out[$key]); } }
private static function guess($path) { $ext = \IO\File::ext($path); $out = 'images_dir'; foreach (static::instance()->path as $dir => $set) { if (in_array($ext, $set)) { $out = $dir; break; } } return $out; }