Closed (fixed)
Project:
Simple Background image formatter
Version:
8.x-1.4
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
24 Jul 2019 at 03:41 UTC
Updated:
25 Aug 2023 at 22:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
aimevpI have been using this module with this patch and noticed that when I select a newly created media item the image style of the selected image is not generated. Attached is a new patch that adds my fix to the original patch.
The patch also cleans and simplifies the code a bit of the new media formatter.
I have not yet tested if the same problem occurs when using the original "image" formatter but I'm guessing the "createDerivative" function could be of use there as well. But that may be better suited in a new issue.
Comment #3
nelslynn commentedThanks for the patches. The image path is not working (Public://IMAGE_FOLDER/IMG_FILE_NAME). I had to modify the background style in the twig template to this:
<div class="{{ background_image_selector }}" style="background-image: url('{{file_url(image_uri)}}');"></div>I know there's probably another solution, but adding "file_uri()" gives the full file path. This works for the inline style version only.
This happens using ddev as a development platform. Am I missing something?
Comment #4
jacobbell84 commented@nelslynn, looks like there was a bug with using the original image vs an image style. This latest patch should fix that issue.
Comment #5
zulljin commentedHey,
I'll review patch and apply after testing.
Comment #6
jacobbell84 commentedComment #7
ConradFlashback commented#4 works well for me, please commit (after Christmas obviously :) )
Comment #8
bramvandenbulcke commentedI'm looking for a module to support background images with media entities. There are different modules supporting background images but none of them currently support media entities (only regular image fields).
I was really happy to see this patch. I was testing on a Drupal 9 install and applied the patch to this modules, version 1.7.
It's not working for me. This is the output:
Error: Call to undefined method Drupal\file\Entity\File::url() in /Users/Bram/Sites/drupal9-test/modules/contrib/background_image_formatter/src/Plugin/Field/FieldFormatter/BackgroundMediaImageFormatter.php on line 130 #0 /Users/Bram/Sites/drupal9-test/core/lib/Drupal/Core/Field/FormatterBase.php(89): Drupal\background_image_formatter\Plugin\Field\FieldFormatter\BackgroundMediaImageFormatter->viewElements(Object(Drupal\Core\Field\EntityReferenceFieldItemList), 'en')
Comment #9
ConradFlashback commented@Zulljin Any news about the #4 test and commit?
Thanks
Comment #10
msabares commentedThis patched replaces the deprecated function of url() with createFileUrl() for Drupal 9
Comment #11
ConradFlashback commented10 works thanks.
Comment #12
zulljin commentedHi, Great news, I was test it. Patch #10 works fine.
Comment #14
zulljin commentedFixed in 2.0.3.