Questions tagged [media]

Drupal core has some modules to handle images and other media files, for example the Image module and the Media module.

Filter by
Sorted by
Tagged with
1 vote
1 answer
390 views

How to get product variation media file url using jsonapi?

I'm using the following jsonapi GET request to retrieve product variations for a product: /jsonapi/commerce_product/default/0ea927c7-b62d-45c9-8bec-dc3d16215276/variations?include=field_images ...
iamfredrik's user avatar
1 vote
2 answers
3k views

How to access url of Remote Video, Document and Image inside twig template?

I have a field called Media (machine name: field_media) inside of a content type. This field Media takes the media types of Remote video, Image, and Documents. I am currently trying to render this ...
Joe Spinelli's user avatar
3 votes
1 answer
1k views

How to add captions to media library items?

Anyone know how to associate a caption to a image that gets uploaded into a media library field? I can get the name of the file to show up but I can't see how to associate a caption to the image. I ...
Michael McGinn's user avatar
0 votes
2 answers
420 views

Is there an easy way to get the image derivatives links?

I'm working with complex image styles, and I'd like to be able to load all the different derivatives quickly to check they're being processed correctly. But I don't see how to easily get the links. ...
joachim's user avatar
  • 846
0 votes
1 answer
671 views

What is the token for the file download link of a media entity?

Using the linked_field module and the [paragraph:field_pbpresentation_file:entity:url] token, I get the edit link for the media entity, not the link to download the file itself. What token should I ...
Interlated's user avatar
  • 1,415
0 votes
1 answer
127 views

Editing media for content editor results in a 404

We have a custom role, location_editor, which is assigned to users who can only manage media and one content type. These are the role's media permissions. And if the user now tries to enter any valid ...
Andreas's user avatar
  • 392
0 votes
1 answer
249 views

Can't add an image extension to the field_image of the Article content type

I need to upload an image with the webp extension and add it as the main image of a content item with the "Article" content type. Since its field_image doesn't have the webp extension by ...
user avatar
4 votes
1 answer
2k views

How can I use core's WebP support instead of the WebP module?

According to the change record, Drupal 9.2 supports WebP for better image compression. I've been using the WebP module on my 9.1 site to serve WebP images, but it has a performance-killing bug and I ...
Patrick Kenny's user avatar
1 vote
0 answers
111 views

Why do drupal-media elements not get rendered in Layout Builder CKEditor?

In Layout Builder, add a custom block. When editing the block in CKEditor, add an image using "Insert from Media Library" button. Exit CKEditor. Re-edit the block in CKEditor. Result: I do ...
Liam Morland's user avatar
0 votes
0 answers
20 views

Image field input renders with type text instead of file

(Drupal newb - please go easy and give references that help me learn how to debug stuff in Drupal myself, thank you!) I've taken over a Drupal site with 7.80. There's a type called Event which has a ...
mozboz's user avatar
  • 101
0 votes
1 answer
145 views

Unable to preview media items

I have a node page where, in the WYSIWYG, I have embedded about 50 media items. When I edit the node, I can see this error for some of the media items. An error occurred while trying to preview the ...
Ahmad's user avatar
  • 2,835
0 votes
1 answer
677 views

Programmatically create a new image style

I'm creating my own module and I need to programmatically create an image style to use with a new media type. I found the core/profile/standard/config/optional/image.style.max_1300x1300.yml file whose ...
Superhetja's user avatar
0 votes
0 answers
72 views

How can I make a widget similar to the media library, just for other entities?

I want to make widgets similar to the one that is provided by media library, but just for other entities, for instance Bibliography & Citation or even just other content. Is it possible to build ...
PartyRadio's user avatar
0 votes
1 answer
764 views

How can I change the label on the "Add media" button in media field widget?

I would like to change the label on the button named "Add media" on the media field widget. For instance to write "Add image" or "Add document". How can I change it?
PartyRadio's user avatar
2 votes
3 answers
3k views

How can I get a custom module's file path in a preprocess function?

I've got default images located in a custom module directory and I'd like to load them using hook_preprocess_node(). I then will pass the images to the template file. In the screenshot, I'm loading an ...
sea26.2's user avatar
  • 1,004
2 votes
0 answers
47 views

What is the equivalent of hook_image_styles_alter()?

I would like to allow uploading of SVG images to all the existing image fields with image effect. However, I wouldn't like the image styles to be applied to SVG images, as it is mostly designed for ...
Binny's user avatar
  • 890
2 votes
1 answer
217 views

How I can insert some help text on the ckeditor media embed "Create embed" tab?

How I can insert some help text on the ckeditor media embed "Create embed" tab? Oddly, I can't even find those words together in code. I have a user confused about its use, so I want to ...
shelane's user avatar
  • 511
0 votes
1 answer
238 views

How do I hide static media file URLs?

I have developed a website in Drupal 7. Right now I have a requirement: A page should display a PDF file (already generated). Only authenticated users should have access to view or download this file, ...
mayur3868's user avatar
0 votes
0 answers
54 views

How to embed image field url in API response?

I have a content type that has a title, body, link, and image field. Then in my php file I have the following: $articles = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['...
Sidney Sousa's user avatar
1 vote
1 answer
455 views

How to create a view of Media images that do not have any Alt Text

For accessibility purposes I want to create a view of Media images that do not have any Alt Text. Creating a view of Media images and also displaying Alt Text is not difficult, as explained is this d....
MrPaulDriver's user avatar
  • 1,027
0 votes
1 answer
296 views

Filter content type by media type

I have a content type that has a media field that can contain audio, video or image, I created a view and I want to filter the view depending on the media type is that possible using Drupal views or ...
Abdelrahman Muntaser's user avatar
-4 votes
1 answer
192 views

I'm using the media video module, how do I upload alternative webm and mp4 versions?

Server hosted video. Using the core video field. I'd like to put up a webm version, but also a mp4 version encoded for safari. Create a video block with 2 source items <video> <source src=&...
Interlated's user avatar
  • 1,415
0 votes
0 answers
23 views

Responsive image folder creation inconsistencies

Just implementing responsive images and find that I have one content type (slider) that the folder structure does not get created as expected in the styles folder. Output is: slider_mobile1 | ---...
Thomas's user avatar
  • 1
-1 votes
1 answer
459 views

How to add and associate Paragraphs to Media Library Images Programmatically

Good day everyone, Our client wants to have this feature where he can upload/reuse multiple images for an article content type. This can be achieved using a Media Library, where I find it tricky is ...
itsfrancisnadal's user avatar
0 votes
0 answers
678 views

How to get the URL of remote video inserted by media field in block or paragraph twig?

How to get the URL of remote video inserted by media field in block or paragraph twig? I am using the paragraphs module to create video galleries from youtube videos. When I use {{ content....
Shakil Ahmad's user avatar
0 votes
1 answer
169 views

I'm attempting to render responsive images and control art direction. Could somebody see whyI can't get breakpoints.yml to be respected?

I'm creating a title/ hero-image section that consists of two 50/50 columns at desktop but then stacks at about tablet (e.g. 1024px) I’m using a custom twig template for this content type. I want ...
user92354's user avatar
1 vote
1 answer
122 views

How can I alter the form to add a new validation handler?

I'm on Drupal 8. I have created a new media bundle (permissions_json) which can be created from /media/add/permissions_json, where administrator user can upload specifically formatted JSON files, and ...
Sorin Lascu's user avatar
0 votes
1 answer
5k views

How do I configure Content Security Policy for base64 images?

I'm using the Content Security Policy module and I placed restrictions on img-src. Set to Self. Additional sources: https://www.google-analytics.com https://ssl.gstatic.com https://www.gstatic.com ...
Patrick Kenny's user avatar
3 votes
2 answers
3k views

How to find the url of a media library image field in a preprocess function?

I have a preprocess function that I am using to grab one of 3 profile images. Basically we're replacing a couple stand-alone image fields with a media library reference field. The goal is to display ...
Patrick Man's user avatar
0 votes
0 answers
47 views

Media 'external video' requests iframe over http instead of https, leading to mixed content errors and blocked video

I have a drupal 9 site where I use the media library. I've created a media type with source "External video", allowing youtube videos. As far as I can see this uses oEmbed. I've added a ...
KeairaSedai's user avatar
0 votes
1 answer
105 views

Twig: Display media library reference user image at particular resolution with alt tag (on /user/1231 page)

On our user page (/user/12345) we want to change the profile image field to be a media library reference field instead. I've created for the user object a new field called field_profile_image that is ...
Patrick Man's user avatar
0 votes
1 answer
95 views

How to display a field when a media is uploaded to the media library field?

I have block settings form where I have a media library field. public function blockForm($form, FormStateInterface $form_state) { $form = parent::blockForm($form, $form_state); $user_input = $...
Ahmad's user avatar
  • 2,835
4 votes
3 answers
920 views

Media library widget: Table instead of grid?

Background I have a multiple-value entity reference field with target type = media. It is used for "document" media, so mostly pdf files. I am using the "Media library" widget ...
donquixote's user avatar
  • 3,632
2 votes
1 answer
877 views

Token does not return full dynamic path to Media Image URL

I'm having trouble configuring Metatag for Open Graph and Twitter Card images. I'm using Drupal 8.9 core Media Image reference field as the source. [node:field_hero_image] (Entity reference field) ...
hotwebmatter's user avatar
  • 2,102
0 votes
1 answer
641 views

How to create Media entity and attach to user field

I'm trying to import user profile pictures from Drupal 7 to Drupal 8. So far I've managed to upload the picture from the url and save it to the file system, create Media entity and use the user id as ...
DamianFox's user avatar
  • 113
0 votes
0 answers
39 views

How to show media only to owners?

In order to allow users to add a remote video from Youtube, I am using the media type in a custom content type. When users create a node of that content type, and add a media, they get a list that ...
Minos's user avatar
  • 1
0 votes
1 answer
110 views

Where are the field formatter settings?

When I'm managing a display for an entity and select a field formatter, some formatters have options available (see screenshot 1). However, when I use that same field formatter in Views, there's no ...
Jon G - Megaphone Tech's user avatar
0 votes
1 answer
1k views

How do I get the public file URI for a media file from jsonapi?

I have an audio file that is stored as Media of type Audio. Now I want to get the link to that file that is usually displayed to site users via jsonapi. For example, when the media entity is rendered, ...
Patrick Kenny's user avatar
1 vote
1 answer
1k views

How can I add player parameters to a core oembed field for a youtube video?

For example, if I enter this url that contains the player parameters to remove controls and autoplay, oembed field on my media type does not allow it ("The given URL does not match any known ...
Nigel Waters's user avatar
  • 1,024
0 votes
2 answers
617 views

Image Files Uploaded via REST got Temporary status - Cannot be refereced by Media Image

Drupal 8.9.11 Image File Uploaded via REST gets "status - Temporary" while setting explicitly "status" case to True server error 403 (code in python) "status": [ ...
Vladimir P.'s user avatar
1 vote
1 answer
2k views

How do I set the height and width for images that use a responsive images style?

When using the core Image module, the height and width of images are automatically set. But when I use the Responsive Images module and a Responsive Image style, then no height or width is set. Users ...
Patrick Kenny's user avatar
-2 votes
1 answer
57 views

Is there a way to add bulk media upload in the modal dialog when using ckeditor and entity embed?

I was a heavy D7 developer and I skipped 8. Now I'm trying to build some sites in 9. Just wrapping my head around what's in core and contrib to get what I need. I was wondering what methods people are ...
Nigel Waters's user avatar
  • 1,024
2 votes
2 answers
2k views

How can I get the parent entity in a media preprocess hook? [duplicate]

I have a paragraph type with a media entity reference field field_paragraph_image_ref. I need to modify the media Twig template depending on a field value of the parent, which is a paragraph entity. ...
Matoeil's user avatar
  • 3,389
0 votes
1 answer
56 views

Media html not rendering in blocks

I'm experiencing an issue on multiple sites where (image) media aren’t appearing in blocks despite working fine in node fields. I first thought it only happened to me when using the linkicon module, ...
Kristoffer Rom's user avatar
0 votes
1 answer
170 views

Image Style issue

I have created an Image style which I am applying in my Blog view. But the Images are not generated in the Blog View Image folder and hence it is not showing up because of the path issue. sites/...
lakshmi H S's user avatar
0 votes
1 answer
1k views

Get media image url in views-view-unformatted template

I'm using drupal 8, in my template I created a file named views-view-unformatted--block-12.html.twig and this is it's content: <div class="row list"> {% for row in rows %} {% set ...
May'Habit's user avatar
  • 133
0 votes
1 answer
104 views

Is it possible to link images to different URLs?

Using View's module it is possible to create a page to display some content horizontally. I have done this using carousel feature. The content type that these contents belong to have an image_field ...
Karel Capek's user avatar
1 vote
1 answer
1k views

Missing updates for Media

After much package dependency finagling via composer, updating PHP, updating MariaDb, etc.. (not as bad as D7 => D8 but still harder than I'd hoped) I managed to update from 8.9 => 9.0.7. I was ...
user92354's user avatar
0 votes
0 answers
314 views

How to create a 'button' which is linked to a Media Document with custom Link text?

I am trying to create the ability for a content editor to add a button to an entity which links to a Media Document. Essentially the requirements are that we can upload a file and that file is ...
Teegan's user avatar
  • 351
0 votes
1 answer
354 views

Why is step 2 of file to media migrate giving me missing bundle error?

I am following the instruction on this page : https://www.drupal.org/project/migrate_file_to_media/issues/3118471 , but with media of bundle document, not image. I have my step 1 yml on this issue ...
Diana's user avatar
  • 3,282

1 2
3
4 5
56