PHPackages                             kisonay/craft-twig-imagebase64 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. kisonay/craft-twig-imagebase64

ActiveCraft-plugin[Templating &amp; Views](/categories/templating)

kisonay/craft-twig-imagebase64
==============================

Base64 encode images within twig templates.

1.1.1(2y ago)54.1k4[2 issues](https://github.com/kisonay/craft-twig-imagebase64/issues)MITPHPPHP ^8.0

Since Jul 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/kisonay/craft-twig-imagebase64)[ Packagist](https://packagist.org/packages/kisonay/craft-twig-imagebase64)[ RSS](/packages/kisonay-craft-twig-imagebase64/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (10)Used By (0)

[![](resources/img/media-encoder.svg)](resources/img/media-encoder.svg)

Twig Image Base64 Encoding
==========================

[](#twig-image-base64-encoding)

A simple Twig extension to create base64-encoded strings from Craft \[Image\] Assets in your Twig templates.

Requirements
------------

[](#requirements)

This Twig extension requires that you pass an instance of a Craft [`Asset`](https://docs.craftcms.com/api/v3/craft-elements-asset.html) in your Twig template. The extension will die gracefully if anything other than that is passed in as the first parameter.

Usage
-----

[](#usage)

### Base64-encode asset

[](#base64-encode-asset)

#### As a Twig Function

[](#as-a-twig-function)

###### With default options

[](#with-default-options)

```
{{ image64(asset) }}

```

###### With `inline` set to `true`

[](#with-inline-set-to-true)

```
{{ image64(asset, true) }}

```

This will return the base64-encoded string in a [data URI scheme](http://en.wikipedia.org/wiki/Data_URI_scheme). The default value is `false`.

#### As a Twig Filter

[](#as-a-twig-filter)

```
{{ asset|image64 }}

```

### Base64-encode thumbnail

[](#base64-encode-thumbnail)

#### As a Twig Function

[](#as-a-twig-function-1)

###### With default options

[](#with-default-options-1)

```
{{ thumb64(asset) }}

```

###### With `inline` set to `true` and width to 200px

[](#with-inline-set-to-true-and-width-to-200px)

```
{{ thumb64(asset, 200, true) }}

```

Second parameter is thumbnail width, default to 100px; Setting third parameter to `true` will return the base64-encoded string in a [data URI scheme](http://en.wikipedia.org/wiki/Data_URI_scheme). The default value is `false`.

#### As a Twig Filter

[](#as-a-twig-filter-1)

```
{{ asset|thumb64 }}

```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance12

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~269 days

Recently: every ~468 days

Total

8

Last Release

961d ago

Major Versions

0.1.0 → 1.0.02018-07-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c238161c68c382d05ef9769c8d1c0b1f85115c2e624b6a3851953baa21b3198?d=identicon)[kisonay](/maintainers/kisonay)

---

Top Contributors

[![kisonay](https://avatars.githubusercontent.com/u/1854267?v=4)](https://github.com/kisonay "kisonay (6 commits)")[![Diewy](https://avatars.githubusercontent.com/u/1014380?v=4)](https://github.com/Diewy "Diewy (1 commits)")[![qrazi](https://avatars.githubusercontent.com/u/7550540?v=4)](https://github.com/qrazi "qrazi (1 commits)")

---

Tags

cmsCraftcraftcmscraft-plugincraft-twig-imagebase64

### Embed Badge

![Health badge](/badges/kisonay-craft-twig-imagebase64/health.svg)

```
[![Health](https://phpackages.com/badges/kisonay-craft-twig-imagebase64/health.svg)](https://phpackages.com/packages/kisonay-craft-twig-imagebase64)
```

###  Alternatives

[lewisjenkins/craft-dynamic-fields

Populate Craft fields with dynamic data using the power of Twig.

14667.0k](/packages/lewisjenkins-craft-dynamic-fields)[nystudio107/craft-minify

A simple plugin that allows you to minify blocks of HTML, CSS, and JS inline in Craft CMS templates.

37461.2k28](/packages/nystudio107-craft-minify)[jalendport/craft-preparse

A fieldtype that parses Twig when an element is saved and saves the result as plain text.

1086.4k](/packages/jalendport-craft-preparse)[craftpulse/craft-colour-swatches

Let clients choose from a predefined set of colours and utilise associated colour codes and class names in your templates.

3530.8k2](/packages/craftpulse-craft-colour-swatches)[superbig/craft-mjml

Render Twig emails with MJML, the only framework that makes responsive email easy.

2627.3k1](/packages/superbig-craft-mjml)[verbb/footnotes

Adds a footnotes feature to CKEditor fields and Twig templates.

213.3k](/packages/verbb-footnotes)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
