PHPackages                             perspeqtive/sulu-media-credits-bundle - 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. [Image &amp; Media](/categories/media)
4. /
5. perspeqtive/sulu-media-credits-bundle

ActiveSulu-bundle[Image &amp; Media](/categories/media)

perspeqtive/sulu-media-credits-bundle
=====================================

Display media credits on your website

1.0.0(1mo ago)318↓100%MITPHPPHP ^8.3

Since May 4Pushed 1mo agoCompare

[ Source](https://github.com/perspeqtive/sulu-media-credits-bundle)[ Packagist](https://packagist.org/packages/perspeqtive/sulu-media-credits-bundle)[ RSS](/packages/perspeqtive-sulu-media-credits-bundle/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

SuluMediaCreditsBundle
======================

[](#sulumediacreditsbundle)

[![Packagist Version](https://camo.githubusercontent.com/a8c40f3a5e0f09cf3cd23e2f9ac47a692e5b2eb5561870539fc74a28702ded10/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70657273706571746976652f73756c752d6d656469612d637265646974732d62756e646c65)](https://packagist.org/packages/perspeqtive/sulu-media-credits-bundle)

The Sulu Media Credits Bundle enables the automatic listing of media credits for media used on the current website. It scans the content via the reference bundle of the current website for linked media and provides them collectively for display.

🚀 Features
----------

[](#-features)

- **Automatic Detection:** Detects media references in various content types.
- **Centralized Display:** Collects all media credits of the current page in one place (e.g., in the masthead).
- **Additional Info:** Considers copyright information and credit fields from media metadata.
- **Memory Optimization:** Uses generators to reduce memory usage.
- **Linking:** Provides links to the pages where the media is used (if applicable).
- **Extendable:** Easily add your own logic for additional content types.

🛠️ Installation
---------------

[](#️-installation)

### Install the bundle via composer:

[](#install-the-bundle-via-composer)

```
composer require perspeqtive/sulu-media-credits-bundle
```

### Activate the bundle

[](#activate-the-bundle)

If you are not using symfony flex, register it in your `config/bundles.php`:

```
return [
    // ...
    PERSPEQTIVE\MediaCreditsBundle\MediaCreditsBundle::class => ['all' => true],
];
```

🛠️ Usage
--------

[](#️-usage)

The bundle provides a Twig function that returns a collection of all media references on the current website.

### Twig Function

[](#twig-function)

Use `media_credits()` to retrieve the credits collection.

```
{% set credits = media_credits() %}

{% if credits.hasCredits %}

        Media Credits

            {% for item in credits %}

                    {{ item.title }}
                    {% if item.credit %}- {{ item.credit }}{% endif %}
                    {% if item.copyright %}(&copy; {{ item.copyright }}){% endif %}

                    {% if item.references %}
                        Used in:

                            {% for ref in item.references.next %}
                                {{ ref.title }}
                            {% endfor %}

                    {% endif %}

            {% endfor %}

{% endif %}
```

### Data Structure

[](#data-structure)

The `media_credits()` function returns a `CreditsCollection` object, which iterates over `Credits` objects.

PropertyTypeDescription`mediaId``int`The ID of the medium`title``string`The title/name of the medium`copyright``string`The copyright field from the metadata`credit``string`The credit field from the metadata`references``MediaReferenceCollection`Collection of references where the file is linkedWithin `item.references.next` (MediaReference):

PropertyTypeDescription`title``string`Title of the linked page/resource`resourceId``string`The target resources unique identifier`resourceType``string`The target resource key like 'pages' or 'articles'`url``string`URL to the resource⚠️ Caution:
-----------

[](#️-caution)

Only images directly used in page-types are considered for reference linking. When using snippets or custom entities, the references are not returned. The credit and copyright information is still available.

🛠️ Extending the Bundle
-----------------------

[](#️-extending-the-bundle)

If you want to support additional media references (e.g., from custom entities or snippets), you can extend the bundle by implementing two interfaces.

### 1. Implement `ReferenceByTypeRepositoryInterface`

[](#1-implement-referencebytyperepositoryinterface)

This interface is responsible for finding references for a specific media ID.

```
namespace App\Repository;

use PERSPEQTIVE\MediaCreditsBundle\Domain\References\ReferenceByTypeRepositoryInterface;

class MyCustomReferenceRepository implements ReferenceByTypeRepositoryInterface
{
    public function findReferences(string $mediaId): iterable
    {
        // Your logic to find references for the given mediaId
        // Should return an iterable of arrays with the following keys:
        // 'referenceTitle', 'referenceResourceId', 'referenceResourceKey', 'referenceLocale'
        yield [
            'referenceResourceId' => '123',
            'referenceResourceKey' => 'my_custom_type',
            'referenceTitle' => 'My Custom Entity Title',
            'referenceLocale' => 'en',
        ];
    }
}
```

### 2. Implement `UrlRepositoryByTypeInterface`

[](#2-implement-urlrepositorybytypeinterface)

This interface is responsible for generating the URL for a found reference.

```
namespace App\Repository;

use PERSPEQTIVE\MediaCreditsBundle\Domain\Url\UrlRepositoryByTypeInterface;

class MyCustomUrlRepository implements UrlRepositoryByTypeInterface
{
    public function find(string $id, string $locale): ?string
    {
        // Generate the URL for your custom entity
        return '/de/my-custom-entity/' . $id;
    }

    public function isResponsible(string $type): bool
    {
        return $type === 'my_custom_type';
    }
}
```

### 3. Register the Services

[](#3-register-the-services)

The bundle uses [tagged iterators](https://symfony.com/doc/current/service_container/tags.html#reference-tagged-services) to collect all repositories.

#### Via Autowire &amp; Autoconfigure

[](#via-autowire--autoconfigure)

If your application uses `autoconfigure: true`, the services will be registered automatically because the bundle registers the interfaces for autoconfiguration.

```
# config/services.yaml
services:
    _defaults:
        autowire: true
        autoconfigure: true

    App\Repository\MyCustomReferenceRepository: ~
    App\Repository\MyCustomUrlRepository: ~
```

#### Manual Registration

[](#manual-registration)

If you don't use autoconfigure, you must add the tags manually:

```
# config/services.yaml
services:
    App\Repository\MyCustomReferenceRepository:
        tags:
            - { name: 'perspeqtive.media_credits.reference_finder_repository' }

    App\Repository\MyCustomUrlRepository:
        tags:
            - { name: 'perspeqtive.media_credits.url_repository' }
```

👩‍🍳 Contribution
----------------

[](#‍-contribution)

Please feel free to fork and extend existing or add new features and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and adapt the documentation.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance93

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 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

Every ~0 days

Total

2

Last Release

35d ago

Major Versions

0.9.0 → 1.0.02026-05-05

### Community

Maintainers

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

---

Top Contributors

[![MarkusHolstein](https://avatars.githubusercontent.com/u/191744183?v=4)](https://github.com/MarkusHolstein "MarkusHolstein (19 commits)")

---

Tags

bundlemediasulucreditscopyrightsulu-bundlemedia-credits

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/perspeqtive-sulu-media-credits-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/perspeqtive-sulu-media-credits-bundle/health.svg)](https://phpackages.com/packages/perspeqtive-sulu-media-credits-bundle)
```

###  Alternatives

[liip/imagine-bundle

This bundle provides an image manipulation abstraction toolkit for Symfony-based projects.

1.7k39.4M236](/packages/liip-imagine-bundle)[sulu/skeleton

Project template for starting your new project based on the Sulu content management system

29734.8k](/packages/sulu-skeleton)[jolicode/media-bundle

A media management bundle for Symfony applications, with Easyadmin and SonataAdmin integrations.

11110.3k](/packages/jolicode-media-bundle)[mediamonks/sonata-media-bundle

A powerful, flexible and easy to use alternative for the existing Sonata Media Bundle

109.8k](/packages/mediamonks-sonata-media-bundle)

PHPackages © 2026

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