当前位置: 首页>>代码示例>>PHP>>正文


PHP asset函数代码示例

本文整理汇总了PHP中asset函数的典型用法代码示例。如果您正苦于以下问题:PHP asset函数的具体用法?PHP asset怎么用?PHP asset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了asset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $id = Auth::user()->ID;
     $files = Input::file('files');
     $assetPath = '/uploads/' . $id;
     $uploadPath = public_path($assetPath);
     $results = array();
     foreach ($files as $file) {
         if ($file->getSize() > $_ENV['max_file_size']) {
             $results[] = array("name" => $file->getClientOriginalName(), "size" => $file->getSize(), "error" => "Please upload file less than " . $_ENV['max_file_size'] / 1000000 . "mb");
         } else {
             //rename filename so that it won't overlap with existing file
             $extension = $file->getClientOriginalExtension();
             $filename = time() . Str::random(20) . "." . $extension;
             // store our uploaded file in our uploads folder
             $name = $assetPath . '/' . $filename;
             $photo_attributes = array('name' => $filename, 'size' => $file->getSize(), 'url' => asset($name), 'user_id' => $id);
             $photo = new Photo($photo_attributes);
             if ($photo->save()) {
                 if (!is_dir($uploadPath)) {
                     mkdir($uploadPath, 0777);
                 }
                 //resize image into different sizes
                 foreach (Photo::getThumbnailSizes() as $key => $thumb) {
                     Image::make($file->getRealPath())->resize($thumb['width'], $thumb['height'])->save($uploadPath . "/" . $key . "-" . $filename);
                 }
                 //save original file
                 $file->move($uploadPath, $filename);
                 $results[] = Photo::find($photo->id)->find_in_json();
             }
         }
     }
     // return our results in a files object
     return json_encode(array('files' => $results));
 }
开发者ID:shankargiri,项目名称:Quantum-Vic-La-Trobe-L4,代码行数:40,代码来源:PhotosController.php

示例2: pageCreateView

 public function pageCreateView($context, $alias, $value = [])
 {
     $menuLevel = [];
     $page = $this->pageModel($context, $alias);
     SEO::setTitle($page->title);
     SEO::setDescription($page->description);
     if ($page->image) {
         SEO::addImages(asset($page->image));
     }
     $value['page'] = $page;
     if ($page->comments and $this->view_comments) {
         $page->load('comments', 'comments.user');
         $value['comments'] = $page->comments;
     }
     $value['view_comments'] = $this->view_comments;
     if ($page->menu) {
         $page->menu->setActiveThis();
         $menuLevel = $page->menu->getMapLevel(true);
         if ($this->list) {
             $childs = $page->menu->getChildsId(true);
             $list = Page::active()->where('context', $this->list)->whereIn('menu_id', $childs)->sort()->with('user', 'fields', 'tag')->paginate(15);
             $value['list'] = $list;
         }
     }
     foreach ($menuLevel as $key => $val) {
         $value['menu_level_' . $key] = $val;
     }
     if ($this->template) {
         $view = $this->view($this->template, $value);
     } else {
         $view = $this->view('tpl.' . $page->template, $value);
     }
     return $view;
 }
开发者ID:jetcms,项目名称:website,代码行数:34,代码来源:PageController.php

示例3: assetTheme

/**
 * Get the current path to assets stored as a theme
 *
 * @param string $asset
 * @param null $theme
 * @return string
 */
function assetTheme($asset = '', $theme = null)
{
    if ($theme == null) {
        $theme = theme();
    }
    return asset('assets/' . $theme . '/' . $asset);
}
开发者ID:maxupunk,项目名称:metin2cms,代码行数:14,代码来源:helpers.php

示例4: index

 /**
  * @return mixed
  */
 public function index()
 {
     $notas = Post::all();
     $imgem = asset('img/paris1.jpg');
     $view = view('blog/index')->with('imagem', $imgem)->with(compact('notas'));
     return $view;
 }
开发者ID:Batalha,项目名称:laravel-blog,代码行数:10,代码来源:BlogController.php

示例5: assets

function assets($name = "assets", $path_url = 0)
{
    if ($path_url) {
        return base_path() . config("path." . $name);
    }
    return asset(config("path." . $name));
}
开发者ID:rochimeiji96,项目名称:hubin,代码行数:7,代码来源:function.php

示例6: getImageAttribute

 public function getImageAttribute($value)
 {
     if ($value) {
         return asset('uploads/topics/' . $value);
     }
     return asset('img/default-topic.jpg');
 }
开发者ID:enhive,项目名称:vev,代码行数:7,代码来源:Topic.php

示例7: wrapper

 /**
  * @param Layout $someLayout
  * @return string
  */
 protected function wrapper(Layout $someLayout)
 {
     $t = $someLayout->getTag();
     /** @noinspection PhpMethodParametersCountMismatchInspection */
     /** @noinspection PhpUndefinedMethodInspection */
     return $t->div(a::id('wrapper'), $t->header(a::c1ass('main-header'), $t->a(a::c1ass('logo'), a::href('/dashboard'), $t->span(a::c1ass('logo-mini'), $t->img(a::src(asset('img/logo-39-45.png')), a::style('margin: 0 0 0 7%;')), $t->b('Solvre')), $t->span(a::c1ass('logo-lg'), $t->img(a::src(asset('img/logo-fav-lg.png'))), $t->b('Solvre'))), $this->navbarTop($t)), $this->aside($t), $this->content());
 }
开发者ID:maveius,项目名称:solvre,代码行数:11,代码来源:AuthView.php

示例8: uploadTextarea

 public static function uploadTextarea($texto, $tipo_midia)
 {
     $nomeTipo = TipoMidia::findOrFail($tipo_midia)->descricao;
     // gravando imagem do corpo da noticia
     $dom = new \DOMDocument();
     $dom->loadHtml($texto, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
     $images = $dom->getElementsByTagName('img');
     // foreach <img> in the submited message
     foreach ($images as $img) {
         $src = $img->getAttribute('src');
         // if the img source is 'data-url'
         if (preg_match('/data:image/', $src)) {
             // get the mimetype
             preg_match('/data:image\\/(?<mime>.*?)\\;/', $src, $groups);
             $mimetype = $groups['mime'];
             // Generating a random filename
             $filename = md5(uniqid());
             $filepath = "uploads/" . $nomeTipo . "/" . $filename . '.' . $mimetype;
             // @see http://image.intervention.io/api/
             $image = Image::make($src)->encode($mimetype, 100)->save(public_path($filepath));
             $new_src = asset($filepath);
             $img->removeAttribute('src');
             $img->setAttribute('src', $new_src);
         }
     }
     return $dom->saveHTML();
 }
开发者ID:safaricco,项目名称:admfw,代码行数:27,代码来源:Midia.php

示例9: style

 /**
  * Generate a link to a CSS file.
  *
  * @param string $url
  * @param array  $attributes
  * @param bool   $secure
  *
  * @return \Illuminate\Support\HtmlString
  */
 public function style($url, $attributes = [], $secure = null)
 {
     $defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'];
     $attributes = $attributes + $defaults;
     $attributes['href'] = asset($url, $secure);
     return $this->toHtmlString('<link' . $this->attributes($attributes) . '>');
 }
开发者ID:kodicms,项目名称:laravel-assets,代码行数:16,代码来源:Html.php

示例10: html

    public static function html($item)
    {
        switch ($item->field) {
            case 'text':
                $value = isset($item->value->text) ? $item->value->text : '';
                $html = '<input id="extend_' . $item->key . '" name="extend[' . $item->key . ']" type="text" value="' . $value . '">';
                break;
            case 'html':
                $value = isset($item->value->html) ? $item->value->html : '';
                $html = '<textarea id="extend_' . $item->key . '" name="extend[' . $item->key . ']" type="text">' . $value . '</textarea>';
                break;
            case 'image':
            case 'file':
                $value = isset($item->value->filename) ? $item->value->filename : '';
                $html = '<span class="current-file">';
                if ($value) {
                    $html .= '<a href="' . asset('content/' . $value) . '" target="_blank">' . $value . '</a>';
                }
                $html .= '</span>
					<span class="file">
					<input id="extend_' . $item->key . '" name="extend[' . $item->key . ']" type="file">
					</span>';
                if ($value) {
                    $html .= '</p><p>
					<label>Remove ' . $item->label . ':</label>
					<input type="checkbox" name="extend_remove[' . $item->key . ']" value="1">';
                }
                break;
            default:
                $html = '';
        }
        return $html;
    }
开发者ID:svita-cz,项目名称:web,代码行数:33,代码来源:extend.php

示例11: show

 function show()
 {
     if ($_GET['id']) {
         return _class('docs')->_show_for($this);
     }
     $docs = _class('docs');
     asset('font-awesome4');
     foreach ($this->_get_assets() as $a) {
         $name = $a['name'];
         $sub = [];
         $sub[] = $docs->_github_link($a['path']);
         $content = $a['content'];
         $info = is_array($content) ? $content['info'] : [];
         if ($info['name']) {
             $sub[] = '<b>' . t('name') . '</b>: ' . $info['name'];
         }
         if ($info['desc']) {
             $sub[] = '<b>' . t('desc') . '</b>: ' . $info['desc'];
         }
         if ($info['url']) {
             $sub[] = '<b>' . t('url') . '</b>: <a href="' . _prepare_html($info['url']) . '">' . _prepare_html($info['url']) . '</a>';
         }
         if ($info['git']) {
             $sub[] = '<b>' . t('git') . '</b>: <a href="' . $info['git'] . '">' . $info['git'] . '</a>';
         }
         $data[$name] = ['name' => $name, 'link' => url('/@object/@action/#' . $name), 'sub' => $sub, 'id' => $name];
     }
     return html()->li($data);
 }
开发者ID:yfix,项目名称:yf,代码行数:29,代码来源:sample_assets.class.php

示例12: store

 /**
  * Proccess image and write the text
  * Verify if the image needs to be downloaded
  * @param Request $request
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['top' => 'max:' . Image::$maxCharCount, 'bottom' => 'required|max:' . Image::$maxCharCount, 'image' => 'required']);
     if ($validator->fails()) {
         $errors = '';
         foreach ($validator->errors()->all() as $error) {
             $errors .= "<br/>" . $error;
         }
         return response('Erro(s) de validação: ' . $errors, 500);
     }
     $image = $request->get('image');
     if (substr($image, -4) !== '.jpg') {
         $image .= '.jpg';
     }
     $imageObject = $this->manager->make(public_path() . '/images/' . $image);
     $token = Image::generateImageToken();
     $path = public_path() . '/images/' . $token . '.jpg';
     $imageObject = $this->write($imageObject, $request->get('bottom'));
     if ($request->get('top')) {
         $imageObject = $this->write($imageObject, $request->get('top'), 'top');
     }
     $result = $imageObject->save($path);
     if ($result) {
         return ['message' => 'Your image was saved successfully', 'token' => $token, 'image_src' => asset('images/' . $token . '.jpg')];
     }
 }
开发者ID:bsampaio,项目名称:Laravel-MemeServer,代码行数:31,代码来源:ImageController.php

示例13: index

 public function index()
 {
     //
     Visitor::log();
     $cats = Categories::orderBy('sort_id', 'asc')->get();
     $products = Products::orderBy('sort_id', 'asc')->get();
     Setting::get('config.mainprod', Null) ? $mainProdImg = asset('/files/img/' . Setting::get('config.mainprod')) : ($mainProdImg = asset('dist/img/photo4.jpg'));
     Setting::get('config.logo', Null) ? $logoMain = asset('/files/img/' . Setting::get('config.logo')) : ($logoMain = asset('dist/img/logo.png'));
     $topProds = DB::table('order_items')->select('product_id', DB::raw('count(*) as total'))->groupBy('product_id')->orderBy('total', 'desc')->take('5')->get();
     $topProdsArr = [];
     foreach ($topProds as $topprod) {
         if (!in_array($topprod->product_id, ['fast', 'np', 'gift'])) {
             if (strpos($topprod->product_id, '0000')) {
                 //dd('consist');
                 $pID = explode('0000', $topprod->product_id);
                 //$topprod->product_id = $pID[0];
                 $prodID = $pID[0];
             } else {
                 $prodID = $topprod->product_id;
             }
             $prodName = Products::findOrFail($prodID);
             //echo $prodName->name;
             array_push($topProdsArr, ['name' => $prodName->name, 'cover' => $prodName->cover, 'link' => $prodName->urlhash]);
         }
         // code...
     }
     //dd(collect($topProdsArr));
     $data = ['cats' => $cats, 'products' => $products, 'PageDescr' => Setting::get('config.maindesc'), 'PageWords' => Setting::get('config.mainwords'), 'PageAuthor' => '', 'PageTitle' => Setting::get('config.maintitle'), 'mainProdImg' => $mainProdImg, 'logoMain' => $logoMain, 'topProds' => $topProdsArr, 'totalNavLabel' => $this->totalNavLabel()];
     return view('catalogPage')->with($data);
 }
开发者ID:ZENLIX,项目名称:LaraShop,代码行数:30,代码来源:CatalogController.php

示例14: asset

 /**
  * Generate an asset path for the application.
  *
  * @param  string  $path
  * @param  bool    $secure
  * @return string
  */
 public function asset($path, $secure = null)
 {
     if (function_exists('asset')) {
         return asset($path, $secure);
     }
     return $path;
 }
开发者ID:euclid1990,项目名称:php-ios-emoji,代码行数:14,代码来源:Emoji.php

示例15: getAvatarUrl

 public function getAvatarUrl()
 {
     if (!$this->avatar) {
         return asset('images/avatars/default.png');
     }
     return $this->avatar->getFileUrl();
 }
开发者ID:kpaxer,项目名称:shcms,代码行数:7,代码来源:User.php


注:本文中的asset函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。