Download the PHP package crobays/asset without Composer
On this page you can find all versions of the php package crobays/asset. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download crobays/asset
More information about crobays/asset
Files in crobays/asset
Informations about the package asset
Crobays / Asset
Simple asset helper to get asset (image, picture, stylesheet, script) elements or urls. Images and pictures have an option to resized and/or cropped dynamically.
Require
"crobays/asset": "dev-master"
Usage
php artisan config:publish crobays/asset
creates a config file in your Lavavel project: app/packages/crobays/asset/config.php
Images
Asset::img('my-image.png', ['w' => 400])
grabs images/my-image.png
to fit width 400px, saves it to img/my-image___w400.png
(also create a @2x version for hi-dpi displays, you need to include retina.js to use this functionality) and returns
<img width="400" src="//assets.example.com/img/my-image___w400.png"
data-src2x="//assets.example.com/img/[email protected]">
Resize and crop the image by providing both width and height
Asset::img('my-image.png', ['w' => 250, 'h' => 250])
grabs images/my-image.png
to fit width 250px and height 250px, saves it to img/my-image___w250-h250.png
and returns
<img width="250" height="250" src="//assets.example.com/img/my-image___w250-h250.png"
data-src2x="//assets.example.com/img/[email protected]">
Provide a size (sizes defined in app/packages/crobays/asset/config.php
)
Asset::img('my-image.png', ['s' => 'xlarge'])
makes image and returns
<img width="960" src="//assets.example.com/img/my-image___w960.png"
data-src2x="//assets.example.com/img/[email protected]">
Provide a special 100% size (defined in the app/packages/crobays/asset/config.php
)
Asset::img('my-image.png', ['s' => '100%'])
makes image and returns
<img width="100%" src="//assets.example.com/img/my-image___w800.png"
data-src2x="//assets.example.com/img/[email protected]">
It allows you to add custom HTML attributes
Asset::img('my-image.png', ['w' => 300, 'class' => 'image'])
makes image and returns
<img width="250" class="image" src="//assets.example.com/img/my-image___w300.png"
data-src2x="//assets.example.com/img/[email protected]">
Pictures
Asset::pic('picture.jpg', ['w' => 1440])
grabs pictures/picture.jpg
to fit width 1440px, saves it to pictures/picture___w1440.jpg
(also create a @2x version for hi-dpi displays, you need to include retina.js to use this functionality) and returns
<img width="1440" src="//assets.example.com/pic/picture___w1440.jpg"
data-src2x="//assets.example.com/pic/[email protected]">
(Inherits also all image functionalty found above)
CSS
(default stylesheet defined in the app/packages/crobays/asset/config.php
)
Asset::css()
Asset::css('another-style.css')
returns
<link type="text/css" href="//assets.example.com/style.css" rel="stylesheet">
<link type="text/css" href="//assets.example.com/another-style.css" rel="stylesheet">
Javascript
(default script defined in the app/packages/crobays/asset/config.php
)
Asset::js()
Asset::js('another-script.js')
returns
<script type="text/javascript" src="//assets.example.com/script.js"></script>
<script type="text/javascript" src="//assets.example.com/another-script.js"></script>
Todo
- phpspec tests
- codeception tests
- comment block documentation
All versions of asset with dependencies
illuminate/support Version 4.2.*
illuminate/config Version 4.2.*
intervention/image Version ~2.0