kunstmaan/media-pagepart-bundle
Provides a media page part for Kunstmaan CMS, letting editors insert images, video and audio into pages via the standard page part workflow. Ships admin form types and Twig templates for consistent front-end rendering.
This bundle wires a MediaPagePart into KunstmaanPagePartBundle, letting editors drop a media item (image/video/file) into any page through the page-part picker. It is a thin, single-page-part bundle from the Symfony 2 era — install it only on a Kunstmaan CMS stack that already uses kunstmaan/pagepart-bundle and kunstmaan/media-bundle.
Minimal setup:
composer require kunstmaan/media-pagepart-bundle
AppKernel (Symfony 2/3 style, which is the only era this supports):new Kunstmaan\MediaPagePartBundle\KunstmaanMediaPagePartBundle(),
bin/console doctrine:schema:update --force
bin/console cache:clear
KunstmaanPagePartBundle (look at the bundle's DependencyInjection/ and Resources/config/ for the exact service/config key in your CMS version — older setups use a pageparts section, newer Kunstmaan versions register page parts through bundle config).Where to look first:
Entity/MediaPagePart.php — the persisted fields (typically a Doctrine relation to Kunstmaan\MediaBundle\Entity\Media).Form/MediaPagePartAdminType.php — how the media picker is exposed in the admin.Resources/views/PagePart/MediaPagePart/view.html.twig — the frontend render template.First use case: add a "Media" page part to a page in the admin, pick an already-uploaded item from the Media section, and confirm the frontend page template includes pagepart.defaultview for it.
Rendering in a page template. The page part exposes a default view; the canonical pattern is to include it from your page template so you never hard-code the bundle's template path:
{% for pagepart in page.pageparts %}
{% if pagepart.defaultview %}
{% include pagepart.defaultview with {'pagepart': pagepart, 'page': page} %}
{% endif %}
{% endfor %}
Guard the media and branch on type. A single media field can hold an image, video, audio, or file, so the view template usually needs to discriminate. Check the media's content type and render accordingly rather than assuming an image:
{% if pagepart.media %}
{% if pagepart.media.contentType starts with 'image/' %}
<img src="{{ pagepart.media.url }}" alt="{{ pagepart.media.name }}">
{% else %}
<a href="{{ pagepart.media.url }}">{{ pagepart.media.name }}</a>
{% endif %}
{% endif %}
For responsive images, lean on kunstmaan/media-bundle's helpers/filters (thumbnails, image sets) rather than calling getUrl() for every breakpoint.
Override the template without forking the bundle. Copy view.html.twig into app/Resources/KunstmaanMediaPagePartBundle/views/PagePart/MediaPagePart/view.html.twig. This is the cheapest extension point and survives Composer updates.
Add caption/link/alt fields. Two viable approaches:
Admin workflow. Editors must upload media under the Media section first; the page part's admin form only lets them select existing media. Document this in your editorial guide — "upload, then select" trips people up.
Integrate with the page-part picker. Once registered, the page part appears in the "Add page part" list on a page; its label comes from translations in the bundle. If you provide a custom admin type, confirm it is used by the registration config, not just defined as a service.
composer why-not kunstmaan/media-pagepart-bundle before assuming it's a code bug. On a modern stack, writing your own page part (entity + AbstractPagePart subclass + admin form + Twig view) is usually faster and safer than vendoring this.Media class by FQCN. A namespace or schema change in a newer media bundle breaks mappings; verify doctrine:schema:validate and that the FK column exists.{% if pagepart.media %}) and consider a cleanup command/query for dangling media_id values.getDefaultView() returns (KunstmaanMediaPagePartBundle:PagePart/MediaPagePart:view.html.twig by convention) and clear the cache.pageparts config key for your Kunstmaan version and dump config (bin/console config:dump-reference kunstmaan_page_part or equivalent).cache:clear and, on Symfony 2/3, assets:install --symlink so admin form assets from the media picker resolve.How can I help you explore Laravel packages today?