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
62 votes
8 answers
81k 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 ...
Justin's user avatar
  • 3,703
55 votes
17 answers
127k 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) ...
Rias's user avatar
  • 723
53 votes
6 answers
37k 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'...
Patrick Kenny's user avatar
37 votes
5 answers
87k 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 ...
Yetispapa's user avatar
  • 697
21 votes
5 answers
24k 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 ...
Evan Johnson's user avatar
21 votes
1 answer
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,...
Mike Cooper's user avatar
20 votes
6 answers
28k 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 ...
Matthew Hui's user avatar
  • 1,368
19 votes
9 answers
25k views

How do I set the theme logo?

How can I set the logo in my custom theme in Drupal 8? I can see that Drupal looks for the logo.svg file. I have a PNG logo.png file that I used in Drupal 7 and I would like to re-use it. I cannot ...
batigolix's user avatar
  • 2,584
18 votes
5 answers
52k 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('')? ...
Serjas's user avatar
  • 1,357
16 votes
7 answers
43k 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 ...
JacobTheDev's user avatar
15 votes
3 answers
14k 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 ...
drmonkeyninja's user avatar
15 votes
2 answers
425 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. "[...
Chance G's user avatar
  • 2,601
14 votes
2 answers
11k views

How do I remove the itok token from the image URLs?

How do I remove the itok token from the image URLs? I found an article discussing it, but it only works for Drupal 7 (https://www.drupal.org/node/1934498). Some articles explains why Drupal adds ...
shi jack's user avatar
  • 143
14 votes
3 answers
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, ...
Aidan's user avatar
  • 481
13 votes
1 answer
5k 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 ?
Satya's user avatar
  • 924
13 votes
4 answers
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 ...
Joe Corneli's user avatar
12 votes
7 answers
18k 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-...
Bart's user avatar
  • 6,934
12 votes
1 answer
15k 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 ...
user56reinstatemonica8's user avatar
12 votes
4 answers
19k 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?
gbwebservice's user avatar
11 votes
3 answers
31k 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: '...
Adeleke Akinade's user avatar
11 votes
4 answers
14k 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 ...
Petro Popelyshko's user avatar
11 votes
2 answers
9k 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 ...
Amy's user avatar
  • 5,662
11 votes
0 answers
2k views

file_copy() does not work [closed]

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 ...
sebastian.roibu's user avatar
10 votes
6 answers
21k 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 ...
artfulrobot's user avatar
  • 4,009
10 votes
5 answers
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 ...
sinini's user avatar
  • 384
10 votes
2 answers
19k 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?
Aruna Singh's user avatar
10 votes
7 answers
19k 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/...
jvc26's user avatar
  • 551
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
10 votes
3 answers
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 ...
PrairieHippo's user avatar
10 votes
6 answers
16k 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/...
silkAdmin's user avatar
  • 2,814
10 votes
4 answers
9k 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 ...
夏期劇場's user avatar
10 votes
2 answers
2k views

Disabling Browse to Library in Media Upload Field

I'm on Drupal 7.2 with the included Media Module. I'm also using WYSIWYG if that matters at all. I'm seeing that when a user clicks the image upload field, they have a choice of either 'web' or '...
user800507's user avatar
9 votes
1 answer
5k 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\...
maartend's user avatar
  • 121
9 votes
2 answers
3k 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 ...
Chris Riley's user avatar
9 votes
3 answers
10k 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 ...
tetranz's user avatar
  • 375
9 votes
3 answers
23k 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. ...
xralf's user avatar
  • 879
9 votes
5 answers
20k 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 ...
rakibtg's user avatar
  • 1,324
9 votes
2 answers
8k 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 ...
Jannis Hell's user avatar
8 votes
3 answers
39k 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']; ?>" /&...
Joe Taylor's user avatar
8 votes
2 answers
8k 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('...
Mistraë's user avatar
  • 392
8 votes
4 answers
9k 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, ...
Undrium's user avatar
  • 389
8 votes
4 answers
10k 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 ...
EB84's user avatar
  • 1,417
8 votes
1 answer
7k views

How do I override the "This image has been removed" message?

I'm using Drupal 8.0.0-beta10. I just tried to add a new basic page node that contains an image hosted in an external website: While it's showing up in the preview, the image isn't showing up once the ...
alexus's user avatar
  • 332
8 votes
1 answer
5k views

How do I automatically generate image styles? [duplicate]

How do I automatically generate different image styles in Drupal 8, for existing images? For example, I have about 10K images in field_image field. I would like to generate thumbnails using my ...
Nicky's user avatar
  • 121
8 votes
3 answers
14k views

Get image's URL as a token for use in Views' replacement pattern

I need to get an image's full URL path as a token that I can use as a replacement pattern in Views. I'm trying to have one thumbnail image link to a larger image. I have the larger image excluded ...
Brad's user avatar
  • 181
8 votes
5 answers
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 ...
chefnelone's user avatar
  • 6,237
8 votes
1 answer
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 ...
EmmyS's user avatar
  • 1,543
8 votes
1 answer
18k 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 ...
Vikram's user avatar
  • 83
8 votes
1 answer
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 ...
user379468's user avatar
  • 2,520
8 votes
3 answers
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 ...
big_smile's user avatar
  • 2,828

1
2 3 4 5
56