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
0 votes
2 answers
360 views

How to use media field with entity browser widget in a frontend theme?

I have created a media field in my content type. In the manage form display, I have selected entity browser as display instead of media library. When I open the node form as admin in an admin theme ...
Ahmad's user avatar
  • 2,835
2 votes
1 answer
667 views

How to get the media that owns a file?

I have a file and I know there is a media that references it. How can I get this media? In the opposite direction, knowing the media id, I can get the file: $media = Media::load($mid); $fid = $media-...
dxvargas's user avatar
  • 950
2 votes
1 answer
949 views

Entity browser or Media Library for PDF uploads?

Client has a custom Content Type for downloadable PDF document detail pages, which contains an entity reference to the File media type. They want Full and Teaser view modes to display a thumbnail ...
hotwebmatter's user avatar
  • 2,102
0 votes
1 answer
142 views

Load Media File in Webform Mail Handler

I want to use a single webform to send download links with specific media files to visitors that fill out that form. For example on an URL like this: https://example.com/downloads?media=1234 The ...
FNGR's user avatar
  • 131
1 vote
1 answer
1k views

How to reuse existing images in field type "Image"

I have custom ContentType with one field of type Image. Currently, when I edit a node I can only upload new images from local to server. I want to have the option to select images already existing on ...
PerfectGamesOnline.com's user avatar
1 vote
0 answers
31 views

How to add an alias filter to the media view?

I have a path alias for my media content provided by pathauto. The media view at 'admin/content/media' shows all the content. I am able to add filter for the media entity name, type, language and ...
awm's user avatar
  • 2,459
0 votes
1 answer
118 views

Image Upload Issues Same Image Different File Name Always Receive This Error

We are currently working on fine tuning and updating the dev backend of our CMS we're rolling out for a new site. I was familiarizing myself with the new system and uploaded some images in error. I ...
4est's user avatar
  • 1
0 votes
0 answers
82 views

Problem with inline images after migration

We recently migrated from D7 to D8 (8.7.6). The migration went OK with the exception of nodes with inline images in the body fields (see the attached screen shot). The images were created in D7 with ...
Dorian Winterfeld's user avatar
0 votes
1 answer
71 views

Image Style Clarification

Can I get some clarification as to why images aren't being generated for a certain image style in a view? Here's my setup; I have an Article content type which allows for a main image to be uploaded. ...
ACanadianCoder's user avatar
1 vote
1 answer
2k views

Custom remote video thumbnail

I'm using the media entity from Drupal core together with the media library, to handle media on my site. I have Remote Video and Image with crop media types. I'm using the crop and image_widget_crop ...
user avatar
0 votes
0 answers
179 views

Can't edit media Image from within node edit

I'm using Media and the Media Library (yes I know this is experimental). And all of the sudden I'm not able to edit my added image when I'm editing a node. In an earlier stage of the website I was ...
Joost's user avatar
  • 1,318
0 votes
1 answer
111 views

Entity:media doesn't exist error when searching for url in "add link" in wysiwyg

When adding a link into a rich text field (wysiwyg) (see images bellow) and searching for a keyword the throbber icon keeps spinning and that's it. I looked at the error logs and found the following, ...
lordZ3d's user avatar
  • 368
4 votes
4 answers
6k views

How can I render a responsive image style from an image in the theme directory?

I am working on template views-view-fields--myview.html.twig. But I do not think it matters what template you are working with for this to work. I found this Twig that can add Drupal responsive ...
paul cappucci's user avatar
1 vote
1 answer
2k views

How can I load all Media of a certain type?

I am trying to load all media items of a certain type but I can't find how to. Is there a way to set a filtering type on something like $media = Media::loadMultiple(); Or do you have to load all ...
dibs's user avatar
  • 818
0 votes
1 answer
1k views

How can I programmatically create a media object and a new file and associate the file with the media object?

I am trying to programmatically create a media object and a file, and then associate the file with the media object. The first part works--I can successfully create the media object and file. But ...
mckinzie25's user avatar
1 vote
1 answer
2k views

How to add multiple values to file/image fields while creating node programmatically?

I have multiple images coming dynamically in array. But while adding those images to node only last file get attached in field and other images only saved in file directory. I have tried everything ...
Pratish Kumar Jha's user avatar
2 votes
0 answers
452 views

Programmatically update remote video thumbnail

Scenario: YouTube video was previously unlisted, so thumbnail not retrieved and now needs to be, or chosen thumbnail has been changed and needs updating. There are a couple of core issues open on ...
William Turrell's user avatar
2 votes
0 answers
70 views

Define a default image when using image as base field in custom entity

I defined a custom entity type with an image base field. Now I want to have a default image which seems to be quite tricky: when I define a default image on a field api field and export the configs I ...
Tobias Krause's user avatar
0 votes
1 answer
789 views

View to display content type and media type

Drupal 8 Say I have 1 content type and 2 media types users can create Content type: Post Media Type: Picture Media type: Movie How can I create a view that pulls all 3? As far as I can see you can ...
ShamelessMedia's user avatar
0 votes
0 answers
87 views

Why are image styles only being generated during a cron run?

I've got a weird thing going where image styles are not being generated after uploading images (as media entities) Image styles are generated during a cron run. Is there a setting for this that I ...
MrPaulDriver's user avatar
  • 1,027
0 votes
1 answer
45 views

Performance for file serving and storage [closed]

I intend to allow users to upload images to my website, but I'm concerned that Drupal's default handling of files might not be cut out for storing and serving potentially thousands of files without ...
otherpoint's user avatar
0 votes
1 answer
43 views

Update the actual file associated with a file entity while keeping the fid?

Media module provides a generic.png file that it copies into /sites/default/media-icons/generic. That file is used on my site ~300 times, but I'd like to replace it with another PNG. Is it possible to ...
Mrweiner's user avatar
  • 1,921
10 votes
3 answers
11k views

Programmatically create media file

I'm trying to programmatically create a media file. Here's what I got so far: $file_data = file_get_contents('http://www.africau.edu/images/default/sample.pdf'); $file = file_save_data($file_data, '...
ravi teja's user avatar
  • 123
0 votes
1 answer
34 views

Creating an image upload input field

I'm creating a image upload input field in blockForm which will output to Twig later. But got stuck due to some stuff. public function blockForm($form, FormStateInterface $form_state){ $form['...
gdmorning520's user avatar
1 vote
1 answer
177 views

How can I export Image Crop configuration with an Image Style for custom module?

I have a custom module I'm re-using on other projects and I want to include an image style with an image crop configuration. Under the configuration menu, I export a single crop item: langcode: en ...
vintorg's user avatar
  • 1,993
2 votes
2 answers
724 views

How to attach media item created during migration to media field in node

I am migrating content from Drupal 7 to Drupal 8. There is an audio field that I am currently moving to media via a custom process during migration. When I get the id of the new media created I can't ...
dibs's user avatar
  • 818
-2 votes
2 answers
305 views

How to get all the entity details which are using specific media?

I have a image "sample.jpg" (In media library) and I used this image in multiple custom blocks of different block types. Now I need an information of all the custom blocks which are using "sample.jpg"...
Ashi's user avatar
  • 127
1 vote
1 answer
157 views

Unset widget tab from media browser programmatically

Need to unset a widget tab from media browser based on the condition of media type supported by the field. Media types: Image and Video. For example, There is a field which references image media ...
echo's user avatar
  • 1,489
0 votes
4 answers
2k views

Can I store media files in the private directory?

The normal behavior, described also in Give access to private files to certain role? seem to be the following. Once configured, files stored in the private directory are inaccessible via a direct ...
Matoeil's user avatar
  • 3,389
1 vote
0 answers
86 views

Caption field with default value inside CKEditor

I activated the caption filter under Text format configuration to add description to media inserted via CKEditor Is there a possibility to add a default value to this caption field whenever I add a ...
Moez Boussetta's user avatar
1 vote
0 answers
57 views

Solr Indexing media fields

I have a bespoke media type that I'd like to index with solr. If I add a new field to an existing Media Type, I can add that field to the solr search using the interface found at admin/config/search/...
A Stanley's user avatar
0 votes
1 answer
613 views

'image_style' entity with ID 'media_library' already exists

Recently updated Drupal to 8.7.1 and I am seeing the following error when running database update: [email protected]:/var/www/html/web $ drush updb -y The following updates are pending: ...
albertski's user avatar
  • 3,447
0 votes
1 answer
437 views

Media images link to their own image

I have inherited a site which had no image management. Instead each image field required you to upload an image instead of reuse an existing one. I enabled Media Browser and updated to 8.7. I am also ...
ice70's user avatar
  • 131
2 votes
1 answer
2k views

How to render image uploaded from a configuration form

I'm working on a custom module, that contains a block and I'm currently having an issue to render an image that is being uploaded through a form at the configuration of the block. I'm getting this ...
PhönixGeist's user avatar
1 vote
1 answer
480 views

How to change image style using hook_views_pre_render()

I am trying to adapt the following Drupal 7 code to Drupal 8, in order to set a different image style to every image in a view: // Assigns a random style name to each image function <MODULE_NAME&...
Mike Godin's user avatar
0 votes
0 answers
29 views

How to create product from image

I'm quite desperate right now and pretty newbie with Drupal. Anyhow, I wan't to develop my WordPress site and change this current system to Drupal. So now i'm able to set user specified galleries and ...
Petri Kajander's user avatar
0 votes
1 answer
46 views

Why cannot I get the path of a video? [closed]

I can't manage to get the video link of a media, I can achieve this with a picture but with videos it doesn't work. This is the code I am using. function slider_get_uri_by_media($media, $style = '...
user avatar
0 votes
0 answers
135 views

Entity with custom field, how to get these field in template?

I have created a Slider entity with the drupal console, with the website interface I create some fields to this entity (field_image, field_title, field_subtitle), but I can't manage to get these ...
user avatar
0 votes
2 answers
32 views

Should I share the same image style as much as possible or create different styles for each size?

I have an image field displayed in slightly different sizes. Let's say : 100px X 100px as a view field format 120px X 120px as another view field format 150px X 150px as a node view format My ...
Sona7's user avatar
  • 135
0 votes
1 answer
269 views

RewriteBase /folder issues on IIS for broken images

I have a Drupal 7 site hosted under a subdirectory say http://example.com/drupal. I am using IIS and SQLSRV. But all the images could not be loaded on the site as these images pointing to http://...
Umesh Patil's user avatar
0 votes
1 answer
166 views

Show full image path D8

I have set a Drupal 8 project into another server with some child directory. This D8 project is working good, But images are not showing due to path missing. E.g My project is setup:- http://abc.xyz....
Pravin Sharma's user avatar
0 votes
2 answers
847 views

Display related media entities

We are using the Basic Page content type and it has an Entity Reference field (field_document) that points to the Document (Media bundle), which has a field_document_tag (taxonomy term field). The ...
usernameabc's user avatar
  • 2,686
0 votes
0 answers
52 views

How to prevent running "updb" twice for upgrading Media

I'm upgrading my custom media modules to use the "core media" in Drupal 8.4.8 I have to run the command "drush [sitename] updb" twice in order to recognise my custom media modules code has been ...
mana's user avatar
  • 401
0 votes
1 answer
147 views

What do I need to pass to the Image class as the first parameter?

I'd like to use the Image API directly to perform few simple operations with images (I'm aware of image styles and for various reasons I would prefer to not use image styles for the application I'm ...
mrlexington's user avatar
0 votes
1 answer
283 views

Optimize image that does not have an image style

We are using the imageapi_optimize modules with the imageapi_optimize_resmushit. We are able to flush the caches for all the image styles and see an improvement. However, there are images that are ...
usernameabc's user avatar
  • 2,686
0 votes
0 answers
92 views

Field_image width in views

I need to build a view with image width and height available in the node devel tab (see image). In the view field list, I can't find those. How can I have these values in my view? note: Having ...
Augusto's user avatar
  • 793
1 vote
1 answer
197 views

How to use articles attached images as background of a div

I'm doing my first site on Drupal 8 and I have a problem. I would like you to help me. In fact I'm trying to get the articles attached images as a background for a div created in the page templates. ...
Worksfather's user avatar
0 votes
2 answers
307 views

Output image src via JSON [closed]

I have worked out how to use dynamic routing and JsonResponse() in a custom controller to output pure JSON, with no HTML at all. I would like to do the same with an image — for the page to output an ...
Spunto the Rat Boy's user avatar
2 votes
3 answers
4k views

Unable to access private file?

I had this issue before, and last time the problem was that node was unpublished. The private file became accessible when the node was published. This time, however, I'm not using a node. I'm just ...
rockstardev's user avatar
  • 1,039
3 votes
4 answers
13k views

How do I programmatically get the URL of an entity referenced media image field using on a custom_preprocess_html() hook on THEME.theme?

Reason: I need to create an Open graph meta tag og:image and pass the URL as content. On THEME_preprocess_html(), I loaded the node using $node = \Drupal::routeMatch()->getParameter('node'); if (...
Regokonda's user avatar
  • 115

1
3 4
5
6 7
56