Closed adrianjean closed 4 months ago
I simplified the image template code to this and still doesn't work:
{% set imageTransform = {
mode: 'crop',
width: 600,
quality: 75
} %}
{% do image.setTransform(imageTransform) %}
<img src="{{ image.getUrl() }}" width="{{image.width}}" style="width:{{image.width}}px;" />
Instead of getting:
<img src="https://website.com/assets-media/images/_600xAUTO_crop_center-center_75_none/953009874.jpg" width="600" style="display: block; width: 600px;">
I get this:
<img src="/assets-media/images/_600xAUTO_crop_center-center_75_none/953009874.jpg" width="600" style="display: block; width: 600px;">
Note the hostname / site URL is missing.
It sounds like the base URL to the files in this filesystem that image assets use is a relative URL. Can you please ensure it is set to an absolute URL that contains the hostname?
oy... Yes, this pointed me in the right direction.
Because in my Settings -> Filesystems
configuration for the filesystem I use @web
in the Base URL field, I need to add in my /config/general.php
a line to define the alias:
// Set aliases to use in the the CP
->aliases([
'@web' => App::env('DEFAULT_SITE_URL'),
'@webroot' => dirname(__DIR__) . '/web',
])
and then in my .env
file define the variable:
DEFAULT_SITE_URL="https://website.com"
It's funny that when testing a sendout using the "Test" function with a test contact, it works without issue, but in the actual full live sending of the Sendout, the issue appears. Wonder why the functions are different.
Probably because live sending happens via a queue job, which may be run from a console request, as opposed to a web request.
Bug Report
Strange problem:
.getUrl()
in the template show fine.Code to display the image in my email template:
Any idea what's happening?
Plugin Version
3.4.0 pro
Craft CMS Version
5.2.5 pro
PHP Version
8.3.9