SS-image-helpers is a SilverStripe Module that provides some template methods, a.k.a., View Helpers, for image usage.
Works fine with SS-Image-Min.
SilverStripe Framework 3.0+
Create a composer.json file:
{
"require" : {
"encoda/ss-image-helpers": "0.0.0"
}
}
Navigate to your project root and run the install command.
$ composer install
Navigate to the root directory of your SilverStripe application and execute git clone https://github.com/encoda/ss-image-helpers.git
Download this zip file and extract it in your SilverStripe root directory.
Returns the AbsoluteUrl
for the Image
of the given file name, starting with the application absoluteBaseURL
.
<img src="$ImageAbsoluteUrl('example.png')" />
<!-- <img src="http://example.com/assets/images/example.png" /> -->
Returns the RelativeLink
for the Image
of the given file name.
<img src="$ImageRelativeLink('example.png')" />
<!-- <img src="assets/images/example.png" /> -->
Returns the Url
for the Image
of the given file name, starting with the application baseURL
.
<img src="$ImageUrl('example.png')" />
<!-- <img src="/assets/images/example.png" /> -->
Returns the html Tag
for the Image
of the given file name.
$ImageTag('example.png')
<!-- <img src="/assets/images/example.png" /> -->
By default, when any of the helpers methods is used to insert an image in the template, the module searches for the image file, by its name, in the following directories:
Images out of the the Images Path are ignored by the helpers. To add new directories to the Images Path, add the following line to your _config.php
.
<?php
SSImageHelpersExtension::add_image_path('my/custom/image/path/');
It also accepts multiple paths at the same time in the form of an array.
<?php
SSImageHelpersExtension::add_image_path(array(
'path/',
'some/image/path/',
'some/new/image/path/',
'and/another/image/path/',
));
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem