Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap out custom code with image_style_url function Issue #6860 #5026

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from

Conversation

bennybobw
Copy link

There is a bunch of custom code in the render function of views_handler_field_file_uri.inc that attempts to generate the image style url. This code breaks when you're using modules such as s3fs which doesn't use the site default file path. I'm swapping that code out instead with image_style_url which fixes the problem.

Fixes Issue 6860

There is a bunch of custom code in the render function of
views_handler_field_file_uri.inc that attempts to generate the image
style url. This code breaks when you're using modules such as s3fs which
doesn't use the site default file path. I'm swapping that code out
instead with image_style_url which fixes the problem.
@backdrop-ci
Copy link
Collaborator

Related to: backdrop/backdrop-issues#6860

@dragonbot
Copy link
Collaborator

Tugboat has finished building a preview for this pull request!

Website: https://pr5026-lnljnm1fwceyeh9z9ju7gjnld6g41f82.tugboatqa.com/
Username: admin
Password: 2268e28b7393

This preview will automatically expire on the 27th of April, 2025.

$data = substr_replace($data, $add_to_url, $insert_at + $file_public_path_strlen, 0);
$url = file_create_url($data);
if (!image_is_svg($url) && !empty($this->options['image_style'])) {
$url = image_style_url($this->options['image_style'], $data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the (unlikely case) that the image module's off, this will fail with "Call to undefined function...". At least, that's what I assume.
The file module's a required one, but the image module isn't.

Copy link
Author

@bennybobw bennybobw Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file already requires the image module to be on because for the options form it calls image_style_options()

I can add conditionals on all that and then in the render section check to see if the module is enabled, write a message to watchdog if it's not and return just the file path.

  1. Does that sound like the proper approach?
  2. Do I need something for the automated tests to test both cases with the image module on and off?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file already requires the image module to be on because for the options form...

That's a good point. How would we get a setting for $this->options['image_style'], anyway, without the image module available. So my first impression, that this odd code exists to avoid image module dependency seems wrong. A check would make more sense in function options_form().

Do I need something for the automated tests to test both cases with the image module on and off?

It's an edge case, I guess, but if you're willing to dig into that, it would be awesome. No requirement, though, as it's unrelated to the broken thumbnail problem. You decide. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Thumbnails broken in image library
4 participants