Wordpress Bundle
  • What is Wordpress Bundle?
  • Getting started
    • Installation
    • Wordpress
    • Router
    • Cron job
    • Templates
  • Reference
    • Argument resolver
    • Controller
      • AdminAction
      • BlogController
      • FrontAction
      • WordpressAction
    • Entity
      • Block
      • Blog
      • Comment
      • File
      • Image
      • Menu
      • MenuItem
      • Post
      • Term
      • User
    • Repository
      • CommentRepository
      • PostRepository
      • TermRepository
      • UserRepository
    • Service
      • PaginationService
      • BreacrumbService
  • Guides
    • Server requirements
    • Install plugins
    • Use Multisite
    • Gutenberg
    • WP Steroids plugin
      • Image options
      • Maintenance
      • Admin pages removal
      • WYSIWYG Editor
      • Feature Support
      • Multi-site configuration
      • Constants definition
      • ACF configuration
      • Menu
      • Custom Post type
      • Advanced permalink settings
      • Custom Taxonomy
      • Templates
      • Page states
      • External table viewer
      • Roles
      • Optimisations
      • Security
      • Search
    • Twig Cookbook
    • Inject variables in all templates
    • Internationalization
    • Extending Wordpress Bundle
    • Error pages
    • Site health
  • Integrations
    • Advanced Custom Fields
      • Install ACF PRO
  • Extras
    • Migrating from 1.x to 2.0
    • Roadmap
    • Changelog
    • Alternatives
Powered by GitBook
On this page
  • Properties
  • Examples

Was this helpful?

  1. Reference
  2. Entity

Image

Single image entity

Properties

Property
Type

ID

Post ID

int

alt

Return alt value

string

cache_path

Only for remote image, return cache path

string

caption

Return caption value

string

date

string

date_gmt

string

description

Post content

string

extension

File extension (.jpg, .png, ... )

string

file

Return relative file path

string

file_content

Return file content, usefull for svg

string

focus_point

array

height

Image height

int

link

Return image link

string

meta(name)

Get post meta

mixed

custom_fields(name)

Get ACF value

mixed

mime_type

Image mime type

string

modified

string

modified_gmt

string

filesize

Return image file size in bytes

int

src

Return image src

string

title

Image title

string

width

Image width

int

Examples

Process remote image

Allowed mime type : image/jpeg, image/jpg, image/gif, image/png

{% set image = Image('https://path-to-remote/image.jpg') %}
{{ image|resize(1280, 680, {insert:['/newsletter/dots.png','bottom-right', 10, 10]}}) }}

Invalidate image cache ( for remote )

Remote image are stored in cache for 30 days, in a controller or an action, you can force cache invalidation

<?php
Image::invalidateCache('https://path-to-remote/image.jpg', true);

Resize an image

Resize an image, and apply filters

<img src="{{ post.thumbnail|resize(1280, 680, {invert:true, flip: true, ext:'jpg'}) }}" alt="{{ post.thumbnail.alt }}"/>

Filter list

  • gcd

  • resize

  • insert

  • colorize

  • blur

  • flip

  • brightness

  • invert

  • mask

  • gamma

  • rotate

  • text

  • pixelate

  • greyscale

  • rectangle

  • circle

  • limitColors

{{ post.thumbnail|resize(1280, 680, {insert:['/newsletter/dots.png','bottom-right', 10, 10]}}) }}

Generate an image placeholder

Generate a transparent image pixel in base64

<img src="{{ pixel(800,600) }}"/>
<img src="{{ placeholder(800,600) }}"/>

Generate an advanced picture template

Return resized and compressed picture HTML

{{ post.thumbnail|picture(1280, 680, {'max-width: 420px':[420,665], 'max-width: 768px':[768,820]})|raw }}

Output

<picture>
    <source media="(max-width: 420px)" srcset="/uploads/image-420x665.webp" type="image/webp"/>
    <source media="(max-width: 420px)" srcset="/uploads/image-420x665.jpg" type="image/jpeg"/>
    <source media="(max-width: 768px)" srcset="/uploads/image-768x820.webp" type="image/webp"/>
    <source media="(max-width: 768px)" srcset="/uploads/image-768x820.jpg" type="image/jpeg"/>
    <source srcset="/uploads/image-1280x680.webp" type="image/webp"/>
    <img src="/uploads/image-1280x680.jpg" alt="My text alt" loading="lazy" width="1280" height="680"/>
</picture>
PreviousFileNextMenu

Last updated 1 year ago

Was this helpful?

Formatted post created date, see

Formatted post created gmt date, see

Return focus point, available when using plugin

Formatted post modified date, see

Formatted post modified gmt date, see

Resize implements methods

Generate a placeholder image using

Image intervention
https://placehold.jp
mysql2date
mysql2date
WP Smartcrop
mysql2date
mysql2date