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
641 views

How to get file uri from entity video

I have some code to get video using view builder. $view_builder = \Drupal::entityTypeManager()->getViewBuilder('media'); $storage = \Drupal::entityTypeManager()->getStorage('media'); $entity_id =...
Aldi Alhafidzi's user avatar
1 vote
1 answer
70 views

Reusable documents with media

With the Media module in the core of Drupal 9 in the Media type document there is the field field_media_document with the option "display". When I use a Media field in a content type how do ...
nicola's user avatar
  • 41
1 vote
0 answers
286 views

JSON-API upload image file

I have been struggling to set up headless Drupal with React js. I did manage to upload the image via JSON API, as per instruction here But I am not able to display the image. It would be great if ...
Rdb's user avatar
  • 11
0 votes
1 answer
256 views

How can I display a larger image when clicking on a thumbnail for an image field? [closed]

Many of the answers are related to Drupal 7, but I'm asking for Drupal 8/9. I have an image field and currently display it as a 100x100 thumbnail. I want to link it to a larger image or make it into a ...
Patoshi パトシ's user avatar
0 votes
1 answer
430 views

Get proper ID from media entity for file loading purposes

I'm attempting to load the file attached to a media entity used in a field attached to a paragraph in order to create a url to the file. $vid = $paragraph->get($field_name)[0]?->entity?->...
Amy's user avatar
  • 5,662
0 votes
0 answers
89 views

Alt attributes are not updating even though I deleted alt in media items

I am trying to remove alt attributes for the decorative images to make them screen reader-friendly. I deleted some of the alt attributes and updated some from media library but the media being used on ...
Anil Thapa's user avatar
0 votes
1 answer
628 views

Creating remote video media entity programmatically not generating thumbnail

Using Drupal 9.4.1, I am creating a remote video media entity programmatically and for some reason the title and thumbnail are not being created. They are created when cron runs so in my terminal when ...
Ronnie's user avatar
  • 487
0 votes
1 answer
960 views

Image styles - How to resize uploaded images and force an aspect ratio

I'm looking for a solution to resize uploaded images while maintaining a desired aspect ratio instead of cropping them. We can configure some preset Image styles, but it seems we can only : Resize : ...
Decoy_Octopus_'s user avatar
0 votes
0 answers
124 views

drupal-media ckeditor tag not well rendered for remote and local video

i'm running a 9.3.16 drupal site with media and media_library modules enabled. I've three types of media entities : video, remote video and image. I can upload and display the three types of media on ...
Frédéric Hébert's user avatar
0 votes
0 answers
201 views

How to create a media entity via rest api

Getting a 422 Unprocessable Entity while trying to create a media entity via rest api. I've failed to find any docs regarding what params/entity type I need. This is how I usually create entities via ...
Abdul Sadik Yalcin's user avatar
0 votes
1 answer
145 views

How to display in a block the media used in a node?

On my Drupal 9 installation, I created nodes with Media images integrated with CKEditor. This is not an image field in the node type, but an image embedded in node content with Media and CKEditor. How ...
zoulou66's user avatar
0 votes
1 answer
238 views

Broken Image styles don't generate

I am on Drupal 9.3 Set the Private file system path in settings.php file $settings['file_private_path'] = '../private'; Create a folder name outside the "web" folder named "private"...
Prashant Chauhan's user avatar
0 votes
1 answer
682 views

Generate a Media entity from a remote URL?

I want to create embeddeable "media" similar to how embedding YouTube or Vimeo videos work. When a URL is pasted in, I want to store this as a media entity (its own type) and then render it ...
Kevin's user avatar
  • 27.8k
1 vote
1 answer
724 views

How do I apply the `loading="lazy"` attribute to responsive media?

On my Drupal 9 installation when I create an "image" field, Drupal automatically adds the loading="lazy" attribute. When I create a "media" field with an "Adaptive ...
zoulou66's user avatar
0 votes
1 answer
272 views

Media Library results filtered by user

I am working on a project that will be using 100's users and potentially thousands of users. The users will be required to upload at the very least 5 images and possibly some PDF files. Created a ...
John Machado's user avatar
1 vote
1 answer
1k views

Link in URL field to Media File

Before the Update to the latest DruPal 8, we were able to link to public://foo/bar.pdf to a file which was in /sites/default/files/. No the public:// prefix does not work anymore in the URL input ...
Alex's user avatar
  • 87
1 vote
0 answers
244 views

Programmatically attach an image to a field

I am using Drupal 9.3.13 on localhost. I generate successfully a QR Code based on the .SVG format and store that image on public://. I created various field types, one of which is a field_file_svg ...
mariosdaskalas's user avatar
1 vote
1 answer
319 views

How to add new fields to the 'edit media' dialog box on media embeds

I'm attempting to add a new select box to the dialog box that pops up when choosing 'edit media' on a media embed in a WYSIWYG. I'm referring to the dialog box that presents options like 'caption' and ...
Amy's user avatar
  • 5,662
2 votes
1 answer
355 views

Use a different twig media template if it is being rendered inside a WYIWYG

I have a twig template for a media entity that I wish to be able to embed into a WYIWYG. I am able to, however the entity has issues rendering when inside the ckeditor that aren't present when ...
Amy's user avatar
  • 5,662
0 votes
1 answer
786 views

Programmatically change view mode of media field

I'm attempting to change the view mode of a media field programmatically. I've created a view mode called 'modal'. I created a mytheme_preprocess_media hook and attempted to change the view mode a ...
Amy's user avatar
  • 5,662
0 votes
1 answer
169 views

Upload directory with no prefix (://) was not found for file uploads

I am not able to get file uploads of any type to work on my Drupal instance when I attempt to add media using the built in form. When I upload an image file, I get: And looking at the log messages in ...
Anton's user avatar
  • 273
1 vote
1 answer
78 views

Key based access control for private files

I'm building a site that provides paid video content, for embedding in customer's own sites. I'm successfully controlling access to the nodes that contain the video content based on purchasable user ...
griz's user avatar
  • 194
0 votes
0 answers
521 views

How can I use the custom image as thumbnail for Youtube videos?

i want to use custom image as thumbnail for remote video (youtube) in my paragraphs , I create one field called custom image under remote video and used the below code. if ($entity->bundle() === '...
vyshnavi's user avatar
2 votes
1 answer
380 views

Why isn't an image from the local domain shown with the explanation that, for security reasons, only images from the local domain are allowed?

I'm running Drupal Core 9.3.7, with basically the default set up. The Basic HTML editor is CKEditor. If I include an image in a page, that image is not shown when I view the page; on inspection, it is ...
Phil Evans's user avatar
1 vote
0 answers
469 views

Need help regenerating images after image cache flush

TL;DR - Flushed image cache for an image style that is used in basically every blog. They are not regenerating on page load. They regenerate when i edit and save the node. Looking for ways to ...
Joshua Jones's user avatar
0 votes
1 answer
557 views

What is the token for an original image URL?

The is the token to get the url for a "large" image style: [node:field_image:large:url] What is the token that will give me the original file URL for the image? That is, not an image style ...
arnoldbird's user avatar
  • 1,173
0 votes
1 answer
982 views

How do I post a PDF?

I followed these steps to post a PDF file to Drupal. Enable JSON API to create at admin/config/services/jsonapi Enable the media POST resource Media /media/{media}/edit: GET, PATCH, DELETE /...
Interlated's user avatar
  • 1,415
0 votes
0 answers
172 views

Display images from private files to public

Is it possible to display private files/images to the public for example with tiwg tweak? I've tried examples from here: https://www.specbee.com/blogs/twig-tweak-in-drupal-9-functions-and-filters ...
exotec's user avatar
  • 1
0 votes
1 answer
149 views

Referencing media from theme settings and display it on front page

In a custom subtheme of classy base theme, I made a theme setting for referencing an image media file. Contents of file theme-settings.php: <?php use Drupal\Core\Form\FormStateInterface; use Drupal\...
Madam Adam's user avatar
0 votes
1 answer
224 views

image.html.twig naming sugestions

I need to customize the image.html.twig template. I have a new content type with an image field (field_tile_image). How can I overwrite the default image template only for one block? I tried different ...
Klapsius's user avatar
  • 101
1 vote
0 answers
173 views

How to change the CKeditor button for media library module [closed]

The Drupal 9 Media Library includes a button for CKeditor. The button depicts an image icon combined with musical notes. We plan to only use this button for video. How can I replace this button with ...
Sarah C's user avatar
  • 480
1 vote
1 answer
108 views

How to make media description show on form view when used as entity reference

Drupal 9... I have a content type of "Resource" which uses a field "download" which references the media type "document", but when I upload a file to the field, it gives ...
wotney's user avatar
  • 202
0 votes
1 answer
129 views

Media migration results in numerous unexpected file usage records (CSV source): How to do this correctly?

I'm migrating lots of records from a non-Drupal site into Drupal 9. The records have file 'attachments,' and I want these to be media in the Drupal site. I have all the files already on the server ...
aharown07's user avatar
  • 382
0 votes
0 answers
160 views

Image compression problem

I keep on running into an issue with image compression on Drupal. I have a set of good quality, clear images, that I'm resizing down to 100px by 100px in CSS. When I resize, the quality worsens and ...
john019's user avatar
  • 11
1 vote
0 answers
517 views

Restrict a Media field to allow selecting only a certain file extension in an existing Media Type

Is there a way to restrict a Media field using an existing Media Type (File) in a Content Type to permit only a certain file extension in that instance? In particular, I need a subset of the permitted ...
Timmah's user avatar
  • 197
1 vote
1 answer
100 views

How do I share Google photos? [closed]

I would like to have all shared albums of a certain google account automatically into a Drupal website. I was able to establish a connection with 'Google_photos_api' and show all shared albums on site ...
Jan Moris's user avatar
0 votes
1 answer
122 views

Content type field to include both media entities and links

I'm new to Drupal and I'm creating a new content type. I know there's two separate fields for media and links, but is there a field that include both? For example, the field is called "News ...
wolves11's user avatar
1 vote
0 answers
22 views

Impossible to access files in /drupal/sites and /drupal/themes after restoring the installation

I restored the files of the Drupal installation, but I'm facing an issue: All the files in /drupal/sites and /drupal/themes are not accessible. I got only 404 errors when trying to load those files. I ...
Paulfr's user avatar
  • 11
1 vote
1 answer
160 views

Reference private file?

I'm making migration plugin which I'm using in first migration and it is creating private file like this: if ($final_destination) { // Create a file entity. $file = File::create([ 'uri' => $...
MilanG's user avatar
  • 509
3 votes
1 answer
43 views

Derive all image styles when user uploading

I have several image styles defined but only thumbnail and medium styles(images) can be derived from the original image. I know those two styles are set in the "manage field" of image and my ...
Bing's user avatar
  • 31
0 votes
0 answers
442 views

Getting validation error webp image upload

I have added a image field to my "Blog" content type. In image field settings 'Allowed file extensions' section include webp format. When I upload webp format image gerring below validation ...
Tushar's user avatar
  • 177
0 votes
1 answer
82 views

Media Library: How can I pre-fill the caption when an image is inserted into a text area?

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 ...
user5113's user avatar
1 vote
1 answer
405 views

Is there a way to pull the 'description' metadata from Media's Remote Videos?

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 ...
quantumized's user avatar
  • 1,217
-1 votes
1 answer
71 views

Is it possible to set up Amazon advertising with the Media module?

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 ...
Mathieu's user avatar
  • 11
-3 votes
1 answer
104 views

Search and pagination in media popup don't work properly [closed]

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 ...
mt.i.1's user avatar
  • 63
1 vote
1 answer
148 views

How can I let users select existing media entities in a webform?

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 ...
Yusmely Mejias's user avatar
0 votes
0 answers
104 views

How can we directly display/download attached document on Media path

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 www....
Regokonda's user avatar
  • 115
0 votes
1 answer
420 views

Some image styles not generating while other are

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 ...
Mrweiner's user avatar
  • 1,921
0 votes
1 answer
496 views

How do I migrate body content with [embed]*[/embed] tags?

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?</...
miststudent2011's user avatar
0 votes
2 answers
2k views

How to render a media field as responsive image?

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....
Letharion's user avatar
  • 27.5k

1
2
3 4 5
56