Questions tagged as ['media']

Drupal core has some modules to handle images and other media files, for example the Image module and the Media module.
Score: 0
Media Library: How can I pre-fill the caption when an image is inserted into a text area?
in flag

If I use Media Library to insert an image into a text area, the image's caption is empty and hidden.

Instead I want the caption displayed by default, pre-filled with text in the format: [Image entity name], by [username], eg '1960s street scene, by David'

(I'm migrating a site that uses D7 + the Scald module to D9 + core Media, and I want to replicate the old site's behaviour in the new site.)

Is there ...

Score: 0
Disable form element depending on media image dimensions
in flag

I have paragraph that contains one media image field and one checkbox field. What I need is to disable that checkbox if selected image media is less then X pixels wide. So it should work when paragraph is opened for editing and also react if image is changed during paragraph editing. How can I achieve that? Is there some event which reacts on media image being changed that can be attached to form?

Score: 1
quantumized avatar
Is there a way to pull the 'description' metadata from Media's Remote Videos?
ng flag

We have a Drupal 9 site that is using Media's Remote Video for YouTube videos. We need to pull the YouTube video's description but I do not see any way to accomplish this. The end result will be to display the YouTube description in a View.

EDIT: The screenshot shows that there is no "description" field in the Remote Video's field mapping.enter image description here

Score: 0
Mathieu avatar
Is it possible to set up Amazon advertising with the Media module?
ph flag

I have a Drupal 9 site with the Media module enabled.

I have subscribed to the Amazon partner program.

Is there a solution to display Amazon iframe in Drupal? I am thinking of the Media module.

Many websites display the product name with the updated price in real time. I did not find anything to fire this.

My question :

Is it possible to set up Amazon advertising with Drupal 9 and the Media module? ...

Score: -3
mt.i.1 avatar
Search and pagination in media popup don't work properly
us flag

In the /admin/content/media page, I have more than one button for the pagination.


The search is working properly.


When I edit a media on some node, in the popup, I only have one button in the pagination.


The search isn't always working. Here, I'm making the search from the page 2, where the image isn't available directly.


It only works when the searched image is on the current page (selected ...

Score: 1
Yusmely Mejias avatar
How can I let users select existing media entities in a webform?
br flag

I am a beginner in drupal and I am creating a course form I would like you to help me with a field in the webform. I need to add a field where users can add an image and documents but from the files that I have in drupal media, not from my computer. I tried with webform entity view and file entity browser but they did not work for me, I can upload my images and documents but from the computer and it is  ...

Score: 0
Regokonda avatar
How can we directly display/download attached document on Media path
us flag

I am trying to directly display/download the attached file when the Media link is reached. Main reason behind this is to avoid providing file path directly.

For example: if a user is visiting then they should be able to view the file directly in the attached media page. This will avoid clicking the file  ...

Score: 0
Some image styles not generating while other are
cn flag

I'm seeing a strange issue where some of our image styles seem to be broken while others work fine. The broken ones are showing the typical signs of the source image existing while the image style url used on the page is broken. I can't seem to find any consistencies -- similar effects are used on working and broken styles, and some broken ones are defaults (thumbnail) while others are customized. Quite ...

Score: 0
miststudent2011 avatar
How do I migrate body content with [embed]*[/embed] tags?
fr flag

Currently I am working on migrating a Drupal 7 site to Drupal 9. The nodes in the site has nodes with content similar to the following one.

<h3><strong>WHAT WILL YOUR NEXT MEAL BE?</strong></h3>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry galley of type and Lor ...
Score: 0
How to render a media field as responsive image?
cn flag

I'm trying to render a media field as a responsive image in a custom twig template.

My naive approach looks like this:

{% include 'responsive-image.html.twig' with {
  "sources": content.field_media,
} %}

which simply yields a series of errors like this:

"0" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core/lib/Drupal/Core/Render/Element.php). 

Presumably one of  ...

Score: 0
c1u31355 avatar
Field UI / image field - empty the whole field / all values
in flag

I'm using an image field with multiple images to manage a custom built gallery. With e.g. IMCE I am able to bulk upload and insert images into this field.

Now I I have to periodically replace the images with new ones - but to do this, I have to click on every single "remove" button to empty the field. This is plain ridiculous since I have about 30 to 100 images per field.

I searched for a module whi ...

Score: 1
iamfredrik avatar
How to get product variation media file url using jsonapi?
us flag

I'm using the following jsonapi GET request to retrieve product variations for a product:


However, the response does not include the file url for the media:

"type": "media--image",
"id": "6af50149-ae35-4a3b-802d-b21c5d863235",
"links": {
"self": {
"href": "http://myurl/en/jsonapi/media/image/6 ...
Score: 0
How to access url of Remote Video, Document and Image inside twig template?
gh flag

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 media inside my twig template as a link to whatever media type it is. For example, if it's a remote youtube video, the link would take you to the video or if it's a pdf document, the link would take you to ...

Score: 3
Michael McGinn avatar
How to add captions to media library items?
tz flag

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 have the image library filed set to allow unlimited items to be uploaded to it so I can have an array of images returned when I display it in my layout builder block. I got the css to style the image array ...

Score: 0
shelane avatar
How do I add a media item with a custom form?
cn flag

I have a custom form that currently uses a managed file field and then stores the value in config. However, if there is ever an issue, the user must remove and upload a new file. I would like them just to be able to select an image from the media library/browser. The selected media item would then be displayed in a template. What type of field can I use to do this?

It seems I missed this question with alm ...

Score: 0
Is there an easy way to get the image derivatives links?
by flag

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. The best I can come up with is opening the node in JSONAPI and, with the patch from, getting the URLs for derivatives from that.

It there something easi ...

Score: 0
Interlated avatar
What is the token for the file download link of a media entity?
km flag

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 use for the download link?

Score: 0
Editing media for content editor results in a 404
ve flag

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 media edit url (for example /media/35/edit - which does exist and was created by him), the result is a 404. The admin user can edit it just fine. The user can also access /media/35/delete without problems. ...

Score: 0
kumar saurabh avatar
Image is not showing on the product edit page after creating the product using API
th flag

I am trying to create a product with a product image on drupal using API. There was nothing given regarding uploading an image in API so I created a custom module under which i used this code to upload my image to the Drupal:

$data = base64_decode($encodedData['content']);
$file = file_save_data($data, 'public://astha.jpg');
$return['id'] = $file->id();

using this my image get uploaded to the follo ...

Score: 0
stckvrw avatar
Can't add an image extension to the field_image of the Article content type
gb flag

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 default, I've added the extension to the "Allowed file extensions" input at the managing tab of the field_image.

When I check the row with the name='field.field.node.article.field_image' in the config DB table, I s ...

Score: 3
How can I use core's WebP support instead of the WebP module?
cn flag

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 would like to use Core if possible.

So when I upgrade to 9.2, how can I replace the WebP module with core's WebP support?

I upgraded to 9.2, uninstalled WebP, and searched for WebP options, but couldn't find  ...

Score: 1
Liam Morland avatar
Why do drupal-media elements not get rendered in Layout Builder CKEditor?
cn flag
  1. In Layout Builder, add a custom block.
  2. When editing the block in CKEditor, add an image using "Insert from Media Library" button.
  3. Exit CKEditor.
  4. Re-edit the block in CKEditor.

Result: I do not see the image (rendered drupal-media element). If I reload the page and edit, I see the rendered image. The image appears the first time I edit in CKEditor but not on subsequent times during the same page load.

Score: 0
Image field input renders with type text instead of file
om flag

(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 bunch of fields including an Image. There are many existing Events where Image upload presumably worked fine in the past. The images are visible when editing those Events.

Problem: The form for adding a new E ...

Score: 0
Stanley Fernandes avatar
How to use [node:title] token as filename for media type fields?
gt flag

I have a Drupal 9 site have two modules FILE (FIELD) PATH module and token is used.

So for a content type, one image field is there where in the File (Field) Path settings I have the file name as [node:title].[file:extension] and it works.

But when I add a media field, and go here admin/structure/media/manage/image/fields/media.image.field_media_image to add the file as [node:title ...

Score: 0
Unable to preview media items
kr flag

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 media. Please save your work and reload this page.

In the browser console, the error is the following. ...

Score: -1
Programmatically create a new image style
us flag

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/ file whose content is the following one.

name: max_1300x1300
label: 'Max 1300x1300'
    id: image_scale
      width: 1300
      height: 1300
      upscale:  ...
Score: 0
matsbla avatar
How can I make a widget similar to the media library, just for other entities?
pe flag

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 similar widgets using configuration or is custom code needed?