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
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 ...
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'...
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 ...
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 ...
21
votes
1answer
1k views

Mass image upload with Storage API and Services API

I am trying to set up a site that will be storing a large amount of images (roughly 50,000 to start with). The strategy for this was to use Storage API and S3 storage to deal with the costs of hosting,...
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 ...
15
votes
2answers
403 views

Hook for Field Duplication

I have a custom module that is formatting the display of an image field, which can accept multiple values. I would like to know what hook I should use to duplicate the first value of the field (e.g. "[...
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('')? ...
14
votes
3answers
12k views

Change image background colour when cropping

Is it possible to change the black background colour to another colour (e.g. white) when cropping an image that is smaller than the crop size? I'm using the "image styles" settings in Drupal 7 to ...
14
votes
1answer
4k views

add watermark to all images uploaded in the site

I am trying add watermark to all the images uploaded by users. Is there any preprocessor for the same? or any module to achieve it ?
13
votes
3answers
3k views

Is it possible to preserve image quality when uploading images?

Is it possible to preserve image quality when uploading images through Drupal7? For example, I take this image: http://f.cl.ly/items/0L3j21030C3O2A3x2w0b/thumb.jpg I upload it using an Imagefield, ...
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 ...
12
votes
4answers
18k views

How can I upload multiple images all at once?

Is there a way to upload multiple images all at the same time in Drupal 7?
12
votes
4answers
8k views

Why can't I add another allowed file extension to a Drupal 7 image field?

I've added the SVG file extension for image uploads via admin/structure/types/manage/image/fields/gallery_image, as you see below: But when I go to upload an image, I'm still not allowed to ...
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-...
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 ...
11
votes
1answer
593 views

Drupal file_copy is not working

I have the following code: $main_image = glob('main*.{jpeg,gif,png,jpg,JPEG,JPG,PNG}', GLOB_BRACE); if (count($main_image) != 1) die("Could not find main picture !"); $file_path = ...
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/...
10
votes
6answers
15k views

How to add a CSS attribute to Image generated with image style

Pretty much all in the title. I would like to add a CSS classes to images generated via a image style theme function, so that the output looks like : <img class="MYCLASS" alt="" src="site.com/...
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 ...
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 ...
9
votes
3answers
9k views

How can I attach an existing server image to an image field rather than uploading a new image file?

Is there a module or some other way of attaching an image to an image field by selecting the image from existing files on the server rather than upload a new image? I'm working on a project where ...
9
votes
2answers
5k views

Print image field with multiple entries from field in twig template

I have a twig template for a custom content type. And it is able to render most fields just fine, but I am unable to print an image field with multiple images. node--mycontenttype.html.twig contains ...
9
votes
3answers
4k views

How do I programmatically add an image while programmatically creating nodes?

I'm writing a script to add nodes programmatically, and I don't know the proper way to add/attach image. Actually I'm not that familiar with Drupal. Here are the (sample) image objects I found 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 ...
9
votes
3answers
799 views

How can I take control of the rendering of a file entity when inlined in text?

There are excellent instructions for how to allow embedding Media into text fields here Setting up WYSIWYG and CKEditor to include Media Browser / Embed Media button. Now I'm trying to control the ...
8
votes
3answers
30k views

How do I get the correct URL of an image field?

I'm trying to print out the URL of an image field using the following code. <img src="<?php echo $field_company_logo['und'][0]['uri']; ?>" alt="<?php echo $company[0]['#markup']; ?>" /&...
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 ...
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 ...
8
votes
4answers
8k views

Get an image from an article/entity

How do I easiest get an image (its path) from the article content type included in Drupal 8? What I have is an entity. Using $image = $node->fields['field_image'] gives me a hell of a structure, ...
8
votes
4answers
10k views

What are the photo gallery/album module choices for Drupal 7?

I am looking to make a Flickr like site that user can create albums, upload photos. With Drupal 6, this can be easily done by CCK, Node Reference, Views. For Drupal 7, it seems difficult since Node ...
8
votes
5answers
19k views

Adding a Image Upload Button in CKEditor

I have installed CKEditor in Wysiwyg profiles. While publishing any node if i click on the image upload button it shows options to add images by a image link, but what is the way to add a dynamic ...
8
votes
5answers
7k views

How to add a description to an image field?

I have a content type which has a field of the image field type. When editing this field I see that I can: Enable Alt field and also can: Enable Title field Is there any way to Add a ...
8
votes
1answer
2k views

What's the “Drupal” way of creating image links?

I know that the correct way to create links in Drupal is to use l($text, $path, array $options = array()). But that only allows for text links. Is there a similar function for creating images that ...
8
votes
3answers
20k views

Resize images automatically

When I insert an image into content area it's usually larger than the content area and the pasted image overlaps with neighbouring blocks. I have to edit HTML and set width and height CSS properties. ...
8
votes
1answer
7k views

Replacing menu items with images

I'm looking for a way to display a menu items as images (with rollover) rather than the usual text links. I found the module Menu Icons, but as the name implies, it's designed to place the icon next ...
8
votes
2answers
6k views

Get an image with style url from an URI in twig

So thanks to 4k4 I finally managed to get my original image URI in a field template via item.content['#item'].entity.uri.value and with {{ file_url(item.content['#item'].entity.uri.value) }} I ...
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 ...
7
votes
2answers
12k views

Generate image URL from FID

I have a custom form in Drupal 8, which has a image upload field. I am storing the file ID of that uploaded image. Now I need to generate the URL of that image. How can I achieve this?
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
4answers
7k views

Add title and alternate text to image automatically?

In my site users can upload content and also images. My goal is that when a user is uploading content to the site, and also an image - the title of the content will be also the image title and the ...
7
votes
11answers
37k views

How do I add an image to a block in Drupal 7?

I want to add an image to a block located in the First Sidebar in Drupal 7. Does anyone know how to do this? Thank you.
7
votes
4answers
2k views

Drupal 7.9 and flexible images

Drupal 7.9 re-introduces height and width attributes to images - I understand this helps improve front-end performance, but it's giving me problems while using flexible images in the vein of ...
7
votes
3answers
4k views

How to prevent users from uploading the same file (image) multiple times?

I have a content type, Image, which allows users to add an image using Drupal 7's built-in image field. I would like to automatically prevent users from adding the exact same image (same filename, ...
7
votes
1answer
4k views

Insert images with Media

I am using Media and Wysiwyg with CKEditor to insert images in the post editing field, and for some reasons I keep getting this code instead of my images. Does anyone know how to fix it? [[ { ...
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\...
7
votes
2answers
5k views

Managed file: What is the proper way of setting #default_value?

$form['picture']['file'] = array( '#type' => 'managed_file', '#title' => t('picture'), '#description' => t('Allowed extensions: gif png jpg jpeg'), '#default_value' => (isset($foo-&...
7
votes
2answers
4k views

Wrapping a rendered file from Media with a link

This is a question related to How to set Media Styles in Media 7.1.2 / Media 7.2.X?. I am using Media 1.2 in a Drupal 7 site to add some fields to images (caption, credit, etc). If I have an image ...
7
votes
1answer
5k views

Why is Drupal deleting my images?

I have images going mysteriously missing from my Drupal site, sometimes several all at once. There are currently only two people who have access to edit these, myself and a manager in Corporate ...