All Projects → radarseven → Craft-Twig-ImageBase64

radarseven / Craft-Twig-ImageBase64

Licence: other
A simple Twig extension for Craft CMS to create base64-encoded images from Assets in your Twig templates.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Craft-Twig-ImageBase64

craft-recaptcha
Integrate Google’s reCAPTCHA into your web forms.
Stars: ✭ 16 (+14.29%)
Mutual labels:  craftcms, craft-plugin, craftcms-plugin
craft-json-snippets
Helps make CraftCMS models in .json
Stars: ✭ 17 (+21.43%)
Mutual labels:  craftcms, craft-plugin, craftcms-plugin
overflow.craft-plugin
A plain text Craft field type, with a soft or hard character limit.
Stars: ✭ 13 (-7.14%)
Mutual labels:  craftcms, craft-plugin, craftcms-plugin
craft-donkeytail
A Craft CMS fieldtype for content managing points on images.
Stars: ✭ 53 (+278.57%)
Mutual labels:  craftcms, craft-plugin, craftcms-plugin
smartdown.craft-plugin
Bringing the unbridled joy of Markdown Extra and Smartypants to your Craft websites.
Stars: ✭ 26 (+85.71%)
Mutual labels:  craftcms, craft-plugin, craftcms-plugin
SecureAssetDownload
Craft CMS plugin for secure asset download URLs
Stars: ✭ 22 (+57.14%)
Mutual labels:  craftcms, craft-plugin, craftcms-plugin
craft-entry-instructions
A simple fieldtype to add instructions.
Stars: ✭ 16 (+14.29%)
Mutual labels:  craftcms, craft-plugin, craftcms-plugin
tablemaker
A user-definable table field type for Craft CMS
Stars: ✭ 39 (+178.57%)
Mutual labels:  craftcms, craft-plugin, craftcms-plugin
craft-react
Client and Server-side React rendering for CraftCMS
Stars: ✭ 40 (+185.71%)
Mutual labels:  craftcms, craft-plugin, craftcms-plugin
craft-entriessubset
Craft field type plugin that extends the core Entries field type to give extra settings
Stars: ✭ 27 (+92.86%)
Mutual labels:  craftcms, craft-plugin, craftcms-plugin
Craft-User-Manual
📚 Help Section Plugin for Craft CMS.
Stars: ✭ 86 (+514.29%)
Mutual labels:  craftcms, craft-plugin, craftcms-plugin
craft-audit
Audit log for Craft 3
Stars: ✭ 18 (+28.57%)
Mutual labels:  craftcms, craft-plugin, craftcms-plugin
craft-assetusage
Craft plugin adds a column to see which assets are used or unused.
Stars: ✭ 28 (+100%)
Mutual labels:  craftcms, craftcms-plugin
commerce-stripe
Stripe payment gateway for Craft Commerce
Stars: ✭ 21 (+50%)
Mutual labels:  craftcms, craft-plugin
craft-cookies
A simple plugin for setting and getting cookies from within Craft CMS templates.
Stars: ✭ 36 (+157.14%)
Mutual labels:  craftcms, craft-plugin
AssetSubfolderAccess
Limits user groups to only access certain asset subfolders
Stars: ✭ 18 (+28.57%)
Mutual labels:  craftcms, craft-plugin
store-hours
Manage business hours with Craft CMS.
Stars: ✭ 60 (+328.57%)
Mutual labels:  craftcms, craft-plugin
pathtools
DEPRECATED This twig plugin for the Craft CMS brings convenient path & url manipulation functions & filters to your Twig templates.
Stars: ✭ 19 (+35.71%)
Mutual labels:  craftcms, craft-plugin
craft3-fallback-site
Failing requests in a multi-site install can fall back to other sites, to prevent 404 errors from missing or disabled entries.
Stars: ✭ 14 (+0%)
Mutual labels:  craftcms, craftcms-plugin
digital-products
Sell digital products with Craft Commerce.
Stars: ✭ 14 (+0%)
Mutual labels:  craftcms, craftcms-plugin

Image Base64

A simple Twig extension for Craft CMS to create base64-encoded strings from Craft Assets in your Twig templates.

Installation

  1. Download the .zip and copy the Craft-Twig-ImageBase64 directory into your Craft plugins directory.
  2. Rename the Craft-Twig-ImageBase64 directory to imagebase64.
  3. Login to your Craft control panel, navigate to Plugins and enable Image Base 64.
  4. Use the {{ image64(asset) }} in your Twig templates to output a base64-encoded string from your Craft Asset.
  5. You're done!

Requirements

This Twig extension requires that you pass an instance of Craft's AssetFileModel in your Twig template.

Usage

The extension can be used as either a Twig filter or as a Twig extension.

As a Twig Function

With default options

{{ image64(asset) }}

With inline set to true

{{ image64(asset, true) }}

This will return the base64-encoded string in a data URI scheme.

As a Twig Filter

{{ asset|image64 }}

Note: In either case, asset must be an instance of Craft's AssetFileModel. The extension will die gracefully if anything other than that is passed in as the first parameter.

Options

inline

default = false

Setting the inline parameter to true will return a base64-encoded string as a data URI scheme. Use this option when setting an <img> src or background-image in CSS.

Examples

Inline option set to false by default:

<img src="{{ image64(asset) }}" alt="Rad Dad!">

As a Twig filter

You can optionally use the extension as a filter instead of a function:

<img src="{{ asset|image64 }}" alt="Rad Dad!">

Inline option set to true:

{% for asset in entry.assets %}
	<img src="{{ image64(asset, true) }}" alt="A rad base64-encoded image with a data URI scheme!">
{% endfor %}

Note: In all examples, asset must be an instance of Craft's AssetFileModel. The extension will die gracefully if anything other than that is passed in as the first parameter.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].