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
22
votes
5answers
22k views

Image styles return Access Denied

I'm using the Insert module to allow users to insert images with a specific image style into a page. After upgrading to Drupal 7.20, the images are not stored in the files/styles folders, and the ...
54
votes
6answers
32k views

How can I automatically upload images on file selection rather than pressing the upload button?

I have a custom content type to allow users to upload images. I'm trying to keep the interface as simple as possible. The content type contains a single image field. This works, but some users don'...
58
votes
7answers
68k views

Rebuild images from image style

I have an image style in Drupal 7. I attached several images to a nodes and display the images based on this style. I then changed the effects on this image style but the existing images are not being ...
42
votes
15answers
67k views

Getting the image URL from a field_image on a node

So I have this Node: object(Drupal\node\Entity\Node)[1862] protected 'values' => array (size=17) 'vid' => array (size=1) 'x-default' => string '7' (length=1) ...
22
votes
3answers
45k views

Get path to theme assets in Twig template

I have a question about getting a path to an image in a Twig template. The image is not assigned to a field or something. Just a static image which is stored in "MYTHEME/image/icon/my-icon.png". In ...
1
vote
1answer
3k views

How can I display a picture from a field as the user picture rather than the drupal default with user-picture.tpl.php?

Because my site requires user pictures to be approved, the default Drupal user picture is not suitable. Instead, I want to show a picture from a field in each user's profile as the user's profile ...
12
votes
1answer
14k views

How to set Media Styles in Media 7.1.2 / Media 7.2.X?

Where is the latest form of the component in the Media project family that allows styles to be defined for Media files? I see a lot of references to the idea that the Media module contains, once ...
2
votes
4answers
8k views

image style (imagecache) images are not being created

Currently i am unable to create images that get resized automaticaly according to the different image styles. This includes the default styles such as thumbnail as well as the custom created styles. ...
8
votes
3answers
10k views

How to find image style URL from within twig template?

I'm implementing a node template that uses an image twice; once in a 'normal' way (i.e. using the image style defined in the field's display configuration for that view mode), and the other is as a ...
14
votes
5answers
47k views

render or print image in a drupal 7 node.tpl?

I am trying to theme a node with tpl and when i tried to print image , I cant find image path like in d6.. which function i have to call to properly output image .. I mean something like theme('')? ...
11
votes
3answers
5k views

Theme Image Style for image located in module directory

Probably coming at this from too much of a Drupal 6 view point but... How do I theme an image in a given image style when that image lives in a module folder? This is driving me batty and I know I'm ...
1
vote
4answers
3k views

How can I reduce the file sizes of the original versions of uploaded image files?

I have a Drupal 7 site that allows users to upload pictures of themselves. While the pictures aren't using much space on the server's filesystem now, I am worried that if my membership grows ...
8
votes
4answers
10k views

Unable to generate the derived image

Today I uploaded my site to the server, and I get errors like the following: Unable to generate the derived image located at public://styles/sponsor_image/public/TerraThermaSponsorLogo.png. Image ...
4
votes
1answer
6k views

How renderable array for an image with style should look like?

I have a custom module that outputs some images. Now, I would like to render them properly. Currently, I use theme() function, kinda similarly to the way shown here1 and here1: echo theme('...
11
votes
7answers
16k views

image_style_url doesn't create images [closed]

I am using image_style_url to get a thumbnail of a picture I added through the administrator interface. // $foo->field_picture['und'][0]['uri'] has value public://foo.jpg image_style_url('foo-...
9
votes
5answers
6k views

force image style generation on save node

I've got still my problem described here Image style, reuse image in field collection item but i gave up to get a solution. A workaround which came up in my mind is to force the generation of ...
6
votes
3answers
2k views

Handling mobile images in responsive theme [closed]

Sorry for the open-handed nature of the question, but I don't know where else to get an answer to this. I'm deciding whether or not go full-force into a responsive Drupal 7 theme, probably the Omega ...
5
votes
5answers
23k views

How to add a background image wallpaper to a drupal site from within the drupal admin?

How can I add a background image wallpaper to a drupal site from within the drupal admin i.e. not editing themes or PHP? I'm not adverse to PHP or themes but adding a background image wallpaper is a ...
4
votes
1answer
8k views

Render image field from node in page.html.twig

I make my first steps with Drupal 8. I have a site with a header image. On a specific content type "Blog" I want to replace the standard header image with a node specific header image. So in the ...
3
votes
3answers
3k views

Move file storage to another server

Consider this: I have one fast server with a Drupal installation but this server does not have access to a lot of disk space. I have another server that isn't quite as fast but does have access to ...
7
votes
3answers
16k views

Rendering an image field in page.html.twig with a custom image style

I'm trying to set up a slideshow that's unique to each page. The code for this needs to be in page.html.twig. I've got the slideshow mostly working, but I can only call the full image URL, not a ...
6
votes
2answers
5k views

Why is there quality loss on my image styles?

This is the original image (610x405) This is the image after applying image style (scale and crop) to 290x190. Both image have the same aspect ration, yet there is visible quality loss on downsizing....
2
votes
1answer
7k views

Save image from URL to a field from a custom module

With a custom module, I'm trying to create a new node, save an image to a node's image field from URL and save the node as well. However when I'm trying to save the node, this error messages comes up ...
10
votes
8answers
18k views

Failing to create thumbnail, medium and large images

When using a new installation of Drupal 7.10, I have set the directory for public uploads to sites/uploads. When I then add an image to a content instance, I get the original uploaded to sites/...
5
votes
4answers
4k views

Loading default image from a node field in page.html.twig

I want to print the default image of a node field into the page.html.twig template file in Drupal 8. On doing my research the easiest approach I could find was {% if node.field_image.entity %} <...
4
votes
2answers
2k views

How to keep underlying file when deleting a Filefield value

I have a Content Type with a FileField (Image, in particular). When one of these values is deleted, then Drupal deletes the underlying file as well (as long as no other nodes reference the same file). ...
0
votes
4answers
2k views

I get image field upload errors with a custom node_add() form

I've exposed a node_add form and styled it for certain roles to use. The form is being displayed in panels, through an 'article' node type using the PHP text filter. Users can create new nodes with no ...
20
votes
6answers
23k views

How to programmatically add image from external URL using media module?

I want to programmatically add an image from an external URL and have the module store and display a local copy of the image. How can I do that? Normally, I would click the "select media" button while ...
9
votes
3answers
3k views

Image Annotations in Drupal 7

What's the best way of creating image annotations in Drupal 7? Ideally, I would like to re-recreate something like in Concept Feedback, where you can post annotations on an image and then display ...
6
votes
3answers
13k views

How to get an image URL from a field in a twig template

I have a node that contains various fields. I am able to get the values of text fields but not an image field. Below is the relevant output of the node variable being dumped in the twig template: '...
3
votes
1answer
8k views

How to get Media entity image (Entity Reference Field) URL in TWIG theme

Apologies if this question has already been asked. However, in my research I found the answers have been for simple image fields which are in default install of Drupal 8. However, in order to have ...
5
votes
5answers
3k views

Drag & drop files into drupal site?

Does anyone know of a module that allows to drag files from users computer into a target area in site (like in gmail or wordpress)? ideally this would work with Image and other modules to insert the ...
7
votes
1answer
10k views

How to change Views field settings programmatically?

I would like to change some field settings in a given view created with Views programmatically. For example, I would like to change the "Formatter" and "Image style" settings of an Image field. This ...
7
votes
1answer
2k views

Form API image preview

I've read many discussions about image preview in fapi with 'managed_file', but I can't find a conclusive answer on how to do this properly in D8. An obvious solution would be to reuse Drupal\image\...
5
votes
1answer
736 views

Delete multiple images at once from a node

I'm having an image field with option set as UNLIMITED to accept infinite images, basically deleting images in single manner is possible, but how it can be possible to delete multiple images at once ...
6
votes
3answers
2k views

How to bulk update image alt and title?

I have a content type with an image field. How do I update all my images to have the node title as the alt and title of the image? I don't want to edit hundreds of nodes... Thank you. Daniel
3
votes
1answer
6k views

Programmatically update node image field (using URI of the image) and get URL in twig

I am trying to update a node image field programmatically. I currently loading the node like this: $node = Node::Load(1); have the URI if the image that I want to set. I have tried this but no luck: ...
3
votes
1answer
4k views

Getting a custom block image field URL in the block Twig template

I have a custom block containing a text field and an image field. I would like to render the block so that the image's URL can be defined as a data attribute of the block's wrapper div so that it can ...
2
votes
3answers
5k views

How do you set the alt attribute with the Media module widget?

I've tried both 7.x-1/7.x-2 branches of the Media module and can't find a way to set the alt-attribute on a image field using the media-widget. When I change to the image widget it's possible to set ...
9
votes
2answers
1k views

Image and Media Best Practices

I am looking for suggestions on Best Practices for D8 and files / media entities. I originally added this as a answer but kiamlaluno evidently felt that it should be a new question in itself so here ...
5
votes
2answers
2k views

Create styled image programmatically

I have a module that create custom PDF with multiple selected nodes and I use the below function to create the link to styled images: $file = File::load($img_id); $imagesPath[] = ImageStyle::load('...
3
votes
1answer
1k views

Is it possible to automatically delete image files that have been uploaded when a node is not saved?

I'm using Drupal 7. On my site, users can add pictures via a content type, Pictures, that makes use of the core image field. If a user uploads an image file and saves the node, then if the node is ...
2
votes
2answers
7k views

How can I convert first page of a pdf as its thumbnail?

I'm trying to build a document sharing site so I need to convert first page of each document as its thumbnail in a grid view. I've found some module like PDF-to-ImageField module, but unfortunately it ...
6
votes
2answers
2k views

Media 7.x-1 Library tab empty

All of the sudden my media library tab becomes empty. I check the permissions and everything seems to be fine.
5
votes
6answers
7k views

How to allow users to rotate a picture upon upload?

On my site, users are able to upload images one at a time as nodes of content type Picture. The Picture content type uses the core (D7) image field. Some of my users have pictures which are taken ...
5
votes
7answers
5k views

Image styles do not work

I am struggling to find a solution for image styles not getting generated. The original pictures get uploaded to the server but no styles or thumbnails are generated. I have checked folder ...
5
votes
2answers
545 views

Add a gallery for every user in a block

I want to be able to add a gallery for each user. I understand how to create a content type. I considered building an image content type. I then thought I could add a view which would only display ...
4
votes
3answers
7k views

Basic Multiple Image Upload to replace standard image uploader

First question on Drupal Answers, hi everyone. Starting off with a very basic question actually: While the standard single image at a time uploader is swell and all, I've got the Galleria module ...
2
votes
3answers
3k views

Remove width and height from img tag in Drupal output (for certain content type)

I want to remove width and height properties from img tags in certain content type Currently it show's like this <img src="http://somesite.com/dostavka-slider-ng.jpg?itok=KDymQiug" width="938" ...
2
votes
1answer
789 views

Set image as permanent in custom block plugin, temporary URI

I'm building a custom block plugin with an image upload which is working fine except for the fact that although the $file->status is set to permanent the URI still comes up as temporary. This is the ...