PHPackages                             codeq/assethelpers - 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. [Caching](/categories/caching)
4. /
5. codeq/assethelpers

ActiveNeos-package[Caching](/categories/caching)

codeq/assethelpers
==================

A package to provide selection of whole asset collection and tags in Neos content editing that keeps caching in mind.

v1.0.0(1y ago)0104PHPCI passing

Since May 30Pushed 1y agoCompare

[ Source](https://github.com/code-q-web-factory/CodeQ.AssetHelpers)[ Packagist](https://packagist.org/packages/codeq/assethelpers)[ RSS](/packages/codeq-assethelpers/feed)WikiDiscussions main Synced 4w ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

CodeQ.AssetHelpers
==================

[](#codeqassethelpers)

A package to provide selection of whole asset collection and tags in Neos content editing that keeps caching in mind.

CodeQ.Asset EelHelper
---------------------

[](#codeqasset-eelhelper)

The `CodeQ.Asset` EelHelper provides utility methods for working with assets, asset collections, and tags in Neos CMS. It is designed to be used in Eel expressions and supports various operations such as retrieving assets by collection or tag, sorting assets, and converting file sizes to human-readable formats.

### Methods

[](#methods)

#### `CodeQ.Asset.getCollectionByIdentifier(string $identifier): ?AssetCollection`

[](#codeqassetgetcollectionbyidentifierstring-identifier-assetcollection)

Retrieves an `AssetCollection` by its identifier.

- **Parameters**:
    - `string $identifier`: The identifier of the asset collection.
- **Returns**: The `AssetCollection` object if found, or `null` if not.

---

#### `CodeQ.Asset.getTagByIdentifier(string $identifier): ?Tag`

[](#codeqassetgettagbyidentifierstring-identifier-tag)

Retrieves a `Tag` by its identifier.

- **Parameters**:
    - `string $identifier`: The identifier of the tag.
- **Returns**: The `Tag` object if found, or `null` if not.

---

#### `CodeQ.Asset.getAssetsByCollection(mixed $collection, ?string $type = null): array`

[](#codeqassetgetassetsbycollectionmixed-collection-string-type--null-array)

Retrieves assets from a given collection, optionally filtered by type.

- **Parameters**:
    - `mixed $collection`: The collection identifier or an `AssetCollection` object.
    - `string\|null $type`: The type of assets to retrieve (`'image'` for images, or `null` for all assets).
- **Returns**: An array of assets in the collection, sorted by title or filename.
- **Throws**:
    - `InvalidArgumentException` if an invalid type is provided.
    - `InvalidQueryException` if the query fails.

---

#### `CodeQ.Asset.getAssetsByTag(mixed $tag, ?string $type = null): array`

[](#codeqassetgetassetsbytagmixed-tag-string-type--null-array)

Retrieves assets associated with a given tag, optionally filtered by type.

- **Parameters**:
    - `mixed $tag`: The tag identifier or a `Tag` object.
    - `string\|null $type`: The type of assets to retrieve (`'image'` for images, or `null` for all assets).
- **Returns**: An array of assets associated with the tag, sorted by title or filename.
- **Throws**:
    - `InvalidArgumentException` if an invalid type is provided.
    - `InvalidQueryException` if the query fails.

---

#### `CodeQ.Asset.humanReadableFileSize(int $size): string`

[](#codeqassethumanreadablefilesizeint-size-string)

Converts a file size in bytes to a human-readable format.

- **Parameters**:
    - `int $size`: The file size in bytes.
- **Returns**: A string representing the file size in a human-readable format (e.g., `1.2 MB`, `512 KB`).

---

### Usage Example

[](#usage-example)

You can use the `CodeQ.Asset` EelHelper in your Fusion code as follows:

```
prototype(Your.Package:Component) {
    assets = ${CodeQ.Asset.getAssetsByCollection('your-collection-identifier')}
    humanReadableSize = ${CodeQ.Asset.humanReadableFileSize(1048576)} # Outputs "1.0 MB"
}

```

### Notes

[](#notes)

- The methods are designed to handle both identifiers and object instances for collections and tags.

CodeQ.AssetCacheTag EelHelper
-----------------------------

[](#codeqassetcachetag-eelhelper)

The `CodeQ.AssetCacheTag` EelHelper provides utility methods for generating cache tags for assets, asset collections, and tags in Neos CMS. These methods are designed to be used in Eel expressions and help manage caching effectively.

### Methods

[](#methods-1)

#### `CodeQ.AssetCacheTag.assetTag(array|Asset $assets): array`

[](#codeqassetcachetagassettagarrayasset-assets-arraystring)

Generates cache tags for a given asset or an array of assets.

- **Parameters**:
    - `array|Asset $assets`: A single `Asset` object or an array of `Asset` objects.
- **Returns**: An array of cache tags for the provided assets.

---

#### `CodeQ.AssetCacheTag.assetCollectionTag(AssetCollection $assetCollection): string`

[](#codeqassetcachetagassetcollectiontagassetcollection-assetcollection-string)

Generates a cache tag for a given asset collection.

- **Parameters**:
    - `AssetCollection $assetCollection`: The asset collection for which the cache tag is generated.
- **Returns**: A string representing the cache tag for the asset collection.

---

#### `CodeQ.AssetCacheTag.assetTagsCachingTag(array|Tag $tags): array`

[](#codeqassetcachetagassettagscachingtagarraytag-tags-arraystring)

Generates cache tags for a given tag or an array of tags.

- **Parameters**:
    - `array|Tag $tags`: A single `Tag` object or an array of `Tag` objects.
- **Returns**: An array of cache tags for the provided tags.

---

### Usage Example

[](#usage-example-1)

You can use the `CodeQ.AssetCacheTag` EelHelper in your Fusion code as follows:

```
prototype(Your.Package:Component) {
    @cache {
        entryTags {
            0 = ${CodeQ.AssetCacheTag.assetTag(asset)}
            1 = ${CodeQ.AssetCacheTag.assetCollectionTag(assetCollection)}
            2 = ${CodeQ.AssetCacheTag.assetTagsCachingTag(tags)}
        }
    }
}

```

###  Health Score

27

—

LowBetter than 46% of packages

Maintenance44

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

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

Unknown

Total

1

Last Release

435d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c898f86932821ebd9add02d4f01864bd4804e1a620083fbc5951af0bb3e9c850?d=identicon)[codeq](/maintainers/codeq)

---

Top Contributors

[![gradinarufelix](https://avatars.githubusercontent.com/u/4405087?v=4)](https://github.com/gradinarufelix "gradinarufelix (6 commits)")

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/codeq-assethelpers/health.svg)

```
[![Health](https://phpackages.com/badges/codeq-assethelpers/health.svg)](https://phpackages.com/packages/codeq-assethelpers)
```

###  Alternatives

[neos/neos-base-distribution

Neos Base Distribution

4466.7k](/packages/neos-neos-base-distribution)[neos/demo

Site package for the Neos Demo Site

18191.3k11](/packages/neos-demo)[flowpack/fullpagecache

Cache full Neos page responses

1489.5k1](/packages/flowpack-fullpagecache)[sandstorm/neostwofactorauthentication

1428.7k](/packages/sandstorm-neostwofactorauthentication)[sitegeist/lostintranslation

Automatic content translations for Neos using the DeepL Api

1343.3k4](/packages/sitegeist-lostintranslation)

PHPackages © 2026

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