Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

This worked for me added these lines in settings.php $settings['file_public_path'] = 'sites/default/files'; $config['image.settings']['suppress_itok_output'] = TRUE; $config['image.settings']['allow_insecure_derivatives'] = TRUE;


1

I gave up on hook_views_pre_render and wound up meeting my requirements with template_preprocess_image_formatter as follows: function <TEMPLATE_NAME>_preprocess_image_formatter(&$variables) { $styles = array('thumbnail', 'medium', 'large'); if ($variables['image']['#style_name'] === 'medium') { $variables['image']['#style_name'] = $styles[...


0

I ran into the same thing. This code ended up working for me use Drupal\file\Entity\File; use Drupal\image\Entity\ImageStyle; use Drupal\node\Entity\Node; $fileName = 'example.jpg'; $destination = "public://images/" . $fileName; $temporaryFile = 'temporary://' . $fileName; file_save_data($photoData, $...


1

Okay, so problem is IIS does not understand our .htaccess file and has its own set of rewrite rules. If someone's facing broken images problem, best is to create an outbound rule which will add your subdirectory into the URL. something like "/sites/all/..." to be rewritten to "/drupal/sites/all/...".


1

I would zoom out the thinking and try to get two things into perspective: user interaction "paths" and which images they "touch" graphics design decision for the image sizes What is the likeliest user scenario for downloading each image size? What is the path your users take through the site that would trigger downloading those image sizes? Will the ...


0

Generally, as @Prestosaurus mentioned, you want to load the smallest image necessary, however there are a couple things to consider Whether the same image is loaded via all the styles or if any individual image would only be loaded once. If you have a single page loading the same image with all 3 styles, that's not as good as just displaying the image with ...


0

Currenty working on that. The code # One month <filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$"> Header set Cache-Control "max-age=2628000, public" </filesMatch> helped me to remove images from the list below https://developers.google.com/speed/


0

Images are hardlinked inside the body field. One way to correct it is to do a search and replace inside the database. Perhaps also pathologic can help correct the problem with broken images. add pathologic support to your desired text formats (congig > content authoring > text formats) make sure you check Correct URLs with Pathologic when visiting a ...


0

Custom Function: function custom_ImageURL() { $imageURL = NULL; $imageFieldName = // However you're getting your field name. // Check the field exists. if (!empty(FieldConfig::loadByName('user', 'user', $imageFieldName))) { // Check there is a primary image. if ($user->$imageFieldName->entity) { $imageURL = $user->$...


0

$image = \Drupal::service('image.factory')->get($image_path); See the whole usage


-1

I think the answer from @ipwa is close but is not quite there. What you want is an output like this: <img src="/fallback.jpg" srcset="/1x.jpg 1x, /2x.jpg 2x, /3x.jpg 3x" /> Here's what you need to do: Enable both the Breakpoint and Repsonsive Image Style modules. Add an image field for uploading 1 image to a content type. Editors should upload the ...


0

Responsive images in Drupal 8 rely on HTML picture element and srcset attribute. That's not something that can be applied to background. Instead you need to user media queries in your CSS to specify different background images for different screen sizes.


0

as for me, this one was caused by nginx config issue just replace "location" directive with one below: location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { try_files $uri @rewrite; expires max; log_not_found off; } and reload nginx sudo systemctl start nginx ( on cent os ) it helped me rights on sites/default/...


0

One of the reasons for this might also be mod_rewrite not being enabled in apache


1

I also had problems with image styles not generating and it turns out it was because mod_rewrite wasn't enabled in my apache2. Hope it helps someone


0

I had a similar issue and it turns out it was because mod_rewrite wasn't enabled in apache2


0

As for me, the issue with broken thumbnails was fixed in nginx config when I added "location" directive below location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { try_files $uri @rewrite; expires max; log_not_found off; } and restarted server, it was never appeared ( using drupal 8.6.13 ) permissions of sites/default/files/styles are 777 for ...


2

Assuming background-image refers to the example: <img src="" style="background-image: url(path/to/image);" />. Background images are different when written as: style="background-image: url(path/to/image);", they do not necessarily use Drupal's render service. A couple of options to try depending on your use case: • Try preprocessing your image field ...


1

If you'd like to get it with Drush on the CLI, use: drush ev "print_r(array_keys(\Drupal::entityTypeManager()->getStorage('image_style')->loadMultiple()));"


0

save the image in another format like png , that will remove existing EXIF info attached to the image that would say to rotate the image.


Top 50 recent answers are included