PHP Class Newscoop\Image\ImageService

Exibir arquivo Open project: sourcefabric/newscoop Class Usage Examples

Protected Properties

Property Type Description
$cacheService
$config array
$orm Doctrine\ORM\EntityManager
$supportedTypes array

Public Methods

Method Description
__construct ( array $config, EntityManager $orm, $cacheService )
addArticleImage ( integer $articleNumber, LocalImage $image, boolean $defaultImage = false ) : Newscoop\Image\ArticleImage Add article image
calculateCutout ( $srcWidth, $srcHeight, $left, $top, $newWidth, $newHeight ) : array Calculates dimensions of cutout in image.
calculateSize ( $srcWidth, $srcHeight, $newWidth, $newHeight, $flags = self::FIT ) : array Calculates dimensions of resized image.
fillImage ( LocalImage $image, array $attributes ) : LocalImage Fill image with custom/default arttributes
find ( integer $id ) : LocalImage Find image
findBy ( array $criteria, array $orderBy = null, integer $limit = 25, integer $offset ) : array Find images by a set of criteria
findByArticle ( integer $articleNumber ) : array Find images by article
generateFromSrc ( string $src ) : void Generate image for given src
getArticleImage ( integer $articleNumber, integer $imageId ) : Newscoop\Image\ArticleImage Get article image
getArticleImageCaption ( integer $imageId, integer $articleNumber, integer $languageId ) : string Get article specific image caption
getArticleImagesCount ( integer $articleNumber ) : integer Get count of article images
getCaption ( LocalImage $image, integer $articleNumber, integer $languageId ) : string Get image caption
getCountBy ( array $criteria ) : integer Get count of images for a set of criteria
getDefaultArticleImage ( integer $articleNumber ) : Newscoop\Image\ArticleImage Get default article image
getImagePath ( ) : string Gets path of local images
getImagine ( )
getSrc ( string $image, integer $width, integer $height, string $specs = 'fit' ) : string Get image src
getThumbnail ( Rendition $rendition, Newscoop\Image\ImageInterface $image ) : Newscoop\Image\Thumbnail Get thumbnail for given image and rendition
getUserImage ( User $user, integer $width = 65, integer $height = 65 ) : string Get user image
inUse ( LocalImage $image ) : boolean Return true if the image is being used by an article.
remove ( LocalImage $image ) : boolean Remove image (files and entity)
removeArticleImage ( ArticleImage $articleImage ) Remove image from article
save ( array $info ) : string Save image
saveArticleImage ( ArticleImage $articleImage, array $values ) : void Save article image
setDefaultArticleImage ( integer $articleNumber, ArticleImage $image ) : void Set default article image
thumbnail ( string $image, integer $width, integer $height, string $specs ) : mixed Get thumbnail for given image
upload ( Symfony\Component\HttpFoundation\File\UploadedFile $file, array $attributes, Newscoop\Image\ImageInterface $image = null, $keepRatio = true ) : LocalImage Upload image and create entity

Private Methods

Method Description
decodePath ( string $path ) : string Decode path
encodePath ( string $path ) : string Encode path
generateImagePath ( integer $imageId, string $extension, boolean $olnyFileName = false ) : string Generate file path for image
generateThumbnailPath ( integer $imageId, string $extension, boolean $olnyFileName = false ) : string Generate file path for thumbnail
updateSchema ( integer $articleNumber ) : void Update schema if needed

Method Details

__construct() public method

public __construct ( array $config, EntityManager $orm, $cacheService )
$config array
$orm Doctrine\ORM\EntityManager

addArticleImage() public method

Add article image
public addArticleImage ( integer $articleNumber, LocalImage $image, boolean $defaultImage = false ) : Newscoop\Image\ArticleImage
$articleNumber integer
$image LocalImage
$defaultImage boolean
return Newscoop\Image\ArticleImage

calculateCutout() public static method

Calculates dimensions of cutout in image.
public static calculateCutout ( $srcWidth, $srcHeight, $left, $top, $newWidth, $newHeight ) : array
return array

calculateSize() public static method

Calculates dimensions of resized image.
public static calculateSize ( $srcWidth, $srcHeight, $newWidth, $newHeight, $flags = self::FIT ) : array
return array

fillImage() public method

Fill image with custom/default arttributes
public fillImage ( LocalImage $image, array $attributes ) : LocalImage
$image LocalImage
$attributes array
return LocalImage

find() public method

Find image
public find ( integer $id ) : LocalImage
$id integer
return LocalImage

findBy() public method

Find images by a set of criteria
public findBy ( array $criteria, array $orderBy = null, integer $limit = 25, integer $offset ) : array
$criteria array
$orderBy array
$limit integer
$offset integer
return array

findByArticle() public method

Find images by article
public findByArticle ( integer $articleNumber ) : array
$articleNumber integer
return array

generateFromSrc() public method

Generate image for given src
public generateFromSrc ( string $src ) : void
$src string
return void

getArticleImage() public method

Get article image
public getArticleImage ( integer $articleNumber, integer $imageId ) : Newscoop\Image\ArticleImage
$articleNumber integer
$imageId integer
return Newscoop\Image\ArticleImage

getArticleImageCaption() public method

Get article specific image caption
public getArticleImageCaption ( integer $imageId, integer $articleNumber, integer $languageId ) : string
$imageId integer
$articleNumber integer
$languageId integer
return string

getArticleImagesCount() public method

Get count of article images
public getArticleImagesCount ( integer $articleNumber ) : integer
$articleNumber integer
return integer

getCaption() public method

Get image caption
public getCaption ( LocalImage $image, integer $articleNumber, integer $languageId ) : string
$image LocalImage
$articleNumber integer
$languageId integer
return string

getCountBy() public method

Get count of images for a set of criteria
public getCountBy ( array $criteria ) : integer
$criteria array
return integer

getDefaultArticleImage() public method

Get default article image
public getDefaultArticleImage ( integer $articleNumber ) : Newscoop\Image\ArticleImage
$articleNumber integer
return Newscoop\Image\ArticleImage

getImagePath() public method

Gets path of local images
public getImagePath ( ) : string
return string

getImagine() public static method

public static getImagine ( )

getSrc() public method

Get image src
public getSrc ( string $image, integer $width, integer $height, string $specs = 'fit' ) : string
$image string
$width integer
$height integer
$specs string
return string

getThumbnail() public method

Get thumbnail for given image and rendition
public getThumbnail ( Rendition $rendition, Newscoop\Image\ImageInterface $image ) : Newscoop\Image\Thumbnail
$rendition Rendition
$image Newscoop\Image\ImageInterface
return Newscoop\Image\Thumbnail

getUserImage() public method

Get user image
public getUserImage ( User $user, integer $width = 65, integer $height = 65 ) : string
$user Newscoop\Entity\User
$width integer
$height integer
return string

inUse() public method

Return true if the image is being used by an article.
public inUse ( LocalImage $image ) : boolean
$image LocalImage Local image
return boolean

remove() public method

Remove image (files and entity)
public remove ( LocalImage $image ) : boolean
$image LocalImage
return boolean

removeArticleImage() public method

Remove image from article
public removeArticleImage ( ArticleImage $articleImage )
$articleImage ArticleImage

save() public method

Save image
public save ( array $info ) : string
$info array
return string

saveArticleImage() public method

Save article image
public saveArticleImage ( ArticleImage $articleImage, array $values ) : void
$articleImage ArticleImage
$values array
return void

setDefaultArticleImage() public method

Set default article image
public setDefaultArticleImage ( integer $articleNumber, ArticleImage $image ) : void
$articleNumber integer
$image ArticleImage
return void

thumbnail() public method

Get thumbnail for given image
public thumbnail ( string $image, integer $width, integer $height, string $specs ) : mixed
$image string
$width integer
$height integer
$specs string
return mixed

upload() public method

Upload image and create entity
public upload ( Symfony\Component\HttpFoundation\File\UploadedFile $file, array $attributes, Newscoop\Image\ImageInterface $image = null, $keepRatio = true ) : LocalImage
$file Symfony\Component\HttpFoundation\File\UploadedFile
$attributes array
$image Newscoop\Image\ImageInterface
return LocalImage

Property Details

$cacheService protected_oe property

protected $cacheService

$config protected_oe property

protected array $config
return array

$orm protected_oe property

protected Doctrine\ORM\EntityManager $orm
return Doctrine\ORM\EntityManager

$supportedTypes protected_oe property

protected array $supportedTypes
return array