PHPackages                             jbennecker/silverstripe-webp - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. jbennecker/silverstripe-webp

ActiveSilverstripe-vendormodule[File &amp; Storage](/categories/file-storage)

jbennecker/silverstripe-webp
============================

31.2k↓50%2[1 PRs](https://github.com/brandcom/silverstripe-webp/pulls)PHP

Since Dec 19Pushed 3mo agoCompare

[ Source](https://github.com/brandcom/silverstripe-webp)[ Packagist](https://packagist.org/packages/jbennecker/silverstripe-webp)[ RSS](/packages/jbennecker-silverstripe-webp/feed)WikiDiscussions ss5 Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

silverstripe-webp
=================

[](#silverstripe-webp)

The Plugin provides a helper to create html `` elements in Silverstripe templates. It supports WebP sources out of the box.

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

[](#requirements)

- SilverStripe 5.x
- rosell-dk/webp-convert ^2.9
- PHP &gt;= 8.1

Install
-------

[](#install)

Install via composer.

`composer require jbennecker/silverstripe-webp`

Register the plugin as a data extension for the `Assets\Image` class:

```
SilverStripe\Assets\Image:
    extensions:
        - jbennecker\Webp\WebpExtension
```

Usage
-----

[](#usage)

The `jbennecker\Webp\Picture` class provides a flexible Api to manipulate your picture in your template file.

To access the Api, call the `getPicture()` method from the `WebpExtension` like so:

```
$MyImage.Picture

```

This will be enough to output a `` with standard configuration.

### Api methods

[](#api-methods)

The class provides multiple methods that can be called in any order. You can chain the methods, as they return the instance of the Picture class.

#### setWidths(int ...$widths)

[](#setwidthsint-widths)

The method will set the widths in the `srcset` attribute in each of the picture's `` tags.

Example:

```
$MyImage.Picture.setWidths(150, 230, 550)

```

Defaults to `350, 750, 1500`.

#### setSizes(string $sizes)

[](#setsizesstring-sizes)

Set the `sizes` attribute on the `` tags a media-query. Defaults to `100w`.

```
$MyImage.Picture.setWidths(370, 750, 1920).setSizes("(min-width: 280px) 100vw, (min-width: 640px) 50vw")

```

#### setFormats(string ...$formats)

[](#setformatsstring-formats)

Control what `` tags / formats will be present. Defaults to webp and jpeg.

Available options:

- webp
- jpg/jpeg

To e.g. disable webp and only get one `` with a jpg `srcset`:

```
$MyImage.Picture.setFormats('jpg')

```

#### setAlt(string $value)

[](#setaltstring-value)

Sets the `alt` parameter on the `` tag. Defaults to the Image's title from the CMS.

#### setCss(string $value)

[](#setcssstring-value)

Sets the `class` parameter on the `` tag.

#### setWidth(int $width)

[](#setwidthint-width)

Set the `width` attribute on the `` tag. Defaults to the Image's original width.

#### setHeight(int $height)

[](#setheightint-height)

Set the `height` attribute on the `` tag. Defaults to the Image's original height.

#### setParam(string $param, string $value)

[](#setparamstring-param-string-value)

Sets a parameter with the name `$param` on the `` tag.

```
$MyImage.Picture.setClass("w-full border shadow-lg").setParam("title", "This is a title")

```

#### setLazyLoading($lazy = true)

[](#setlazyloadinglazy--true)

Control the `loading` attribute. Sets it to `lazy` or `eager`. Defaults to lazy loading.

### The Webp-Method

[](#the-webp-method)

If you just want to quickly convert the image to .webp and use it in your template, you can use the Webp method:

```

```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance54

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 96.4% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/86ac90232d8367beb9bc60f0a438881c9e44b5e9b17b740b5166b5119f9ae737?d=identicon)[brandcom](/maintainers/brandcom)

---

Top Contributors

[![passchn](https://avatars.githubusercontent.com/u/77938819?v=4)](https://github.com/passchn "passchn (27 commits)")[![difunk](https://avatars.githubusercontent.com/u/120631305?v=4)](https://github.com/difunk "difunk (1 commits)")

---

Tags

silverstripesilverstripe-modulewebp

### Embed Badge

![Health badge](/badges/jbennecker-silverstripe-webp/health.svg)

```
[![Health](https://phpackages.com/badges/jbennecker-silverstripe-webp/health.svg)](https://phpackages.com/packages/jbennecker-silverstripe-webp)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M123](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

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