Questions tagged [media]

Drupal core has some modules to handle media files, such as the Image module (Drupal 7) and the Media module (Drupal 8). Other modules handling media are third-party modules.

Filter by
Sorted by
Tagged with
0
votes
1answer
195 views

How to change URL images for CDN

I have a website in Drupal 7 with "N" images in Sites/default/files and I need move this images to CDN. Is this possible?
1
vote
2answers
646 views

How to use an image with Responsive Image style as a background?

We have a need to use the Responsive Image module. The key is that we want to be able to use the image (field_image) field with Responsive Image styles as a background and put the node's title on top ...
0
votes
3answers
477 views

How do you wrap an image with a link?

In Drupal 7 this was done with the l() command and setting the html option to true. I have found the Link::fromTextAndUrl() method in Drupal 8 but no mention of something similar to the html option. [...
0
votes
1answer
145 views

How to relate an image to an article when posting the article in REST API

Using the following code we can post a node trough rest API. However, if there is an image attached to this article we need to post the image node first and then include the image fid in the article.I ...
-1
votes
1answer
72 views

Is it possible to save a view as image?

I have a view with a table and charts and I need to save it as image. Is this possible? It can be an export of the page itself as long as it exports only the contents of the view without menus and ...
3
votes
3answers
2k views

Render image that is linked

I am loading an unmananged image file and would like to render it in a block, but it should be linked. I have an uri (public://...) and I am able to render the image using $build['my_image'] = [ ...
0
votes
1answer
747 views

How can I dynamically get the fields on an image media bundle?

What’s the correct way to get all of the key/values for a bundle on a media entity? I am trying to create a media entity programmatically and I need to get all of the fields on the image bundle. I ...
1
vote
1answer
266 views

How to add a width attribute to a responsive image with srcset?

When using a responsive image with srcset the width and height attributes are not available in twig. Both of them are NULL When an image is uploaded that is too small images are stretched or blown up ...
2
votes
1answer
427 views

How to render an image at its original size?

There are plenty of examples on the internet on how to render a styled image; for instance this one from web omelette: $render = [ '#theme' => 'image_style', '#style_name' => 'thumbnail'...
-1
votes
1answer
23 views

Reuse images in articles with file_field_sources module

I would like to reuse the already posted images in the articles of my blog. I am using the core field_image in articles and when I installed the file_field_sources module, there were no options in ...
0
votes
1answer
142 views

How to properly use media (in core)?

We are converting all of our images to the image type provided by media. What I don't really understand is that there seem to be multiple ways to do this. Am I supposed to give the 'image' media ...
0
votes
2answers
1k views

How do I integrate a Media library to Image Field?

I have a image upload element field in my content type. I need to open a media library when I click on browse. My expectation is to select an image which I have already uploaded before. So I don't ...
1
vote
2answers
732 views

Setting up a grid to carousel?

Alright everyone, I'm sure this is a relatively simple thing, but I'm on the verge of tearing my hair out. What I'm trying to accomplish is setting up images to appear in a grid, that when clicked ...
1
vote
1answer
57 views

Unsupported Operand Types theme_image_style

I'm using the following code to generate a thumbnail and it's URI. The URI works on its own (though it 404's) but whenever I add theme_image_style function it gives a fatal error: "Unsupported operand ...
-1
votes
1answer
33 views

How to change pictures position?

I'm doing a website about tips and tricks to save money. Everything is working fine, except the visual identity, which sucks a bit. I've tried to change the views to give my articles a good looking, ...
1
vote
1answer
1k views

How do I delete files attached with media entity in drupal 8.4.2?

Background: drupal 8.4.2 custom media solution Issue I can not delete files permanently which created as media entity. Reproduce Created an image media entity. /admin/content/files claims status ...
0
votes
2answers
248 views

Is there a way to get multiple image sizes from a single image?

In Drupal 8 Manage display for the image field, I can assign only one image style. I have two image styles: thumbnail and medium. when I upload an image through image uploader, I need to view my ...
0
votes
0answers
23 views

Why am I seeing so many duplicate images in my thumnails folders?

Why am I seeing tons of duplicate images in my sites/default/files/data_export_import/styles/test_thumbnails There are so many in there, like 4 gigs, I'm going over quota, how can I clear this and ...
1
vote
0answers
154 views

How to get all the image files and clean them up on Drupal 8?

On my Drupal 8 website I have created multiple media contents and uploaded image file to each content. When I update new image of a media content, the old image file remains unused in the image ...
0
votes
1answer
177 views

How to add more image styles to an image element in a content type

I have a image field in my content type. In that field the images should be saved in two image sizes. As an example when I uploaded a photo it should save as two photos. One for 200x200 px and one for ...
1
vote
1answer
536 views

How to display all media that references this taxonomy term and its immediate children?

I have a hierarchical taxonomy vocabulary, "Living Things". A simplified excerpt looks like this: Plants --Roses ----Red Rose ----Pink Rose --Orchids ----White Orchid ----Yellow Orchid I have a ...
-1
votes
1answer
97 views

Add image css field in content type

I want to add an image css field in one of my content types. Drupal provides an "alt" and an "title" field for the image, but now I need to add a css field too. Im using the image on a view, and I ...
1
vote
1answer
334 views

Apply Image styles for migrated images

I've done a drupal migration from drupal 6 to drupal 8. While all files are migrated well, image styles are not applying on migrated images. Image styles are applied to the newly added images. I ...
2
votes
2answers
652 views

Add image field or other fields from node to a custom Block in Drupal 8

I am new to Drupal and I am learning pretty fast. However I am stuck on an issue. I need to make a custom Block for my content (node) images. There is a system-made content block which pulls from ...
0
votes
1answer
30 views

Rules (not) triggered with Bulk Media Upload

Rules (not) triggered with Bulk Media Upload I have a node type called 'uploads' that includes a user reference field to make each upload particular/available to a certain user. I have added a rule ...
0
votes
1answer
43 views

How to display (automatically in a field) all media that references this node?

I have a content type, "Fruit". Using that content type I have created a "Bananas" node. It contains text and link fields that constitute "banana information". I have media type, "Fruit Image", with ...
-1
votes
1answer
343 views

How can I embed a video in a drupal page that is remotely hosted in Amazon s3 cloudfront?

When I try to embed a video in a drupal page that is hosted remotely on an Amazon s3 server, I get the following error message: "Could not find a video provider to handle the given URL" I have the ...
2
votes
1answer
62 views

Drupal 8 Rules and Media

I want to publish Media associated with content when the content is published. Is that possible with rules? If so, what are the conditions I need to set? The conditions I have set are: Node ...
1
vote
1answer
399 views

How to modify the image output for just one content type using Responsive Images?

There is a field_image (image) field on the basic content type. Using the Responsive Image, we enabled it on the Default view mode for the field_image field using a Responsive Image style. The ...
1
vote
1answer
2k views

Render media entity image

I have a media entity target id and I want to render the image contained in it. I've loaded the media entity using Media::load, I was hoping to use something like render() on some rendererable array ...
-1
votes
1answer
33 views

Targeting Specific Image Templates

I'm trying to implement a script for lazy loading images on my site and I'm not sure how to target specific image templates. I need to change the src attribute to data-src and add a class. All ...
-1
votes
1answer
40 views

How to add a custom field image in a block, for a style background-image: url()

I'm trying to add a background image field to a block, when template-c is selected using the style property: <?php //here I can set if template AB or C 1,2,3 if ($rows[0]['field_template'] == '...
3
votes
3answers
1k views

Lazy Load inline images in Drupal 8

We have nodes with a lot of inline images in them. And we are looking for a solution on how to lazyload inline images in Drupal 8. We are trying to get the Blazy module to lazyload them but it is not ...
2
votes
0answers
263 views

Adding protection against hotlinking to .htaccess breaks generation of styled images

Drupal 8.3.4, Apache, Image Magick toolkit (via Imagick module). I recently discovered some annoying hotlinking to my site siphoning my bandwidth and decided to disable it. Added the following to /...
1
vote
0answers
604 views

How should I solve a module load order problem in a custom install profile?

I'm building a custom install profile for Drupal 8.4. It uses the new core Media module, and includes custom config files for the entity forms for media's image and file entities. One of those changes ...
-1
votes
1answer
1k views

Display image/media entities view from node to twig template

Would like to ask how I can output or display the image entities from my entity browser/entity view to the twig template. I'm using the media entity module on drupal and then using views to select and ...
2
votes
1answer
80 views

How to modify the image output for just one content type?

We are using a field_image field across multiple content types. For the basic content type (only) we want to lazy load the images as such it requires the following format. How can this be done for ...
1
vote
3answers
2k views

How to optimize already uploaded images?

Is it possible to compress or optimize images that are already uploaded to the server? What about a method to optimize the images on upload? Goal: Take all existing images, compress them, and then ...
0
votes
1answer
2k views

Import nodes with images

Im trying to create nodes from CSV also with image in one image field. I'm using Migrate modul in Drupal 8 and Migrate from CSV. Data to node works fine, image download and copy works fine but in node ...
2
votes
1answer
1k views

How to use picture element as background image?

With the simple image field we are able to set the image style and use that to set the image as a background for a div tag (see example below). HOwever, as Drupal 8 has Responsive Image module, the ...
1
vote
2answers
287 views

How to get Responsive Image Styles to work with existing images?

We have existing images that never had an image style applied to them. As part of the cleanup, we are now using Responsive Image Module to do this per breakpoint. AFter creating the different image ...
0
votes
1answer
312 views

Anonymous users can't access to image style field

Entity Type : block Field : 'Reference to entity : image style' (field_image_style) Manage display : I display the Entity ID Twig In my twig template, I get the field_image_style data from content....
0
votes
2answers
59 views

How can I enable download link in the Media browser library tab

My media browser has a list of powerpoint and visio files: How can I add a download link or preview it next to each file? The idea is to make it easier for user to choose which file they want before ...
2
votes
1answer
355 views

How to execute ajax action after image file upload with media widget?

I want to prepopulate some node fields with image metadata (using the EXIF module) right after an image is uploaded/inserted in a node image field with media browser widget and before the node is ...
0
votes
1answer
21 views

D7: Empty image upload field when adding a translation

By default when you add a translation your fields get pre-filled with the content of the original language. Is there a way to stop this behaviour for specific fields, in this case an image field. Both ...
0
votes
1answer
121 views

How to Lazyload any src object in node body

Currently using Blazy on Drupal 8. What I am trying to do is figure out how to lazyload any image, iframe, mp4 found in the body. I think I have found a good solution as seen here: https://www.drupal....
1
vote
1answer
476 views

How to add image cache headers?

When doing SEO tests, we consistently seeing a message for cache headers on images. We were thinking of implementing but cannot find the appropriate way to test this as the x-cache still gives a MISS. ...
1
vote
1answer
560 views

(Field type) Link autocompletion for media entities

How can I enable autocompletion for media entities in Link fields? The Link field seems to "know" only nodes, but no media entities. Use case: I've got a paragraph for a "card style" link consisting ...
1
vote
1answer
508 views

Responsive image style with srcset and without sizes

Using this tutorial for example I found out how to use responsive image styles in Drupal 8 without <picture> (which is pretty straight forward anyway). However this approach forces you to use ...
0
votes
1answer
216 views

How to enforce minimum height and width for image while resizing anything larger?

We have a requirement where the minimum and maximum image resolution 480x480 for an image on upload. The reason is that we want the image to be resized to be exactly 480x480. However, whenever we ...