Git Product home page Git Product logo

images's Introduction

Images

Join the chat at https://gitter.im/brabijan/images

This is a simple image storage for Nette Framework

Instalation

The best way to install brabijan/images is using Composer:

$ composer require brabijan/images:@dev

Then you have to register extension in config.neon.

extensions:
	- Brabijan\Images\DI\ImagesExtension

Package contains trait, which you will have to use in class, where you want to use image storage. This works only for PHP 5.4+, for older version you can simply copy trait content and paste it into class where you want to use it.

<?php

class BasePresenter extends Nette\Application\UI\Presenter {

	use Brabijan\Images\TImagePipe;
	
}

Usage

Saving images

/** @var Brabijan\Images\ImageStorage $imageStorage */
$imageStorage->upload($fileUpload); // saves to .../assetsDir/original/filename.jpg

$imageStorage->setNamespace("products")->upload($fileUpload); // saves to .../assetsDir/products/original/filename.jpg

Using in Latte

<a href="{img products/filename.jpg}"><img n:img="filename.jpg, 200x200, fill"></a>

output:

<a href="/assetsDir/products/original/filename.jpg"><img src="/assetsDir/200x200_4/filename.jpg"></a>

Using in Texy!

First you have to register macro into Texy!

$texy = new Texy;
$this->registerTexyMacros($texy);

Now you can just use it. Macro expands native image macro in Texy. Here is the syntax.

[* products/filename.jpg, 200x200, fill *]

If file not found in image storage, macro try to search file in document root. Of course you can add title or floating of image, as you know from pure Texy!

Resizing flags

For resizing (third argument) you can use these keywords - fit, fill, exact, stretch, shrink_only. For details see comments above these constants

images's People

Contributors

brabijan avatar paveljurasek avatar chemix avatar adaamz avatar stancek avatar wodcz avatar rhrebecek avatar gitter-badger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.