cancel
Showing results for 
Search instead for 
Did you mean: 

How to get image path from less file for email (offline) ?

How to get image path from less file for email (offline) ?

Hello,

I'm trying to add a background image to a button in a transactionnal email, I don't know how to get the image path in the less file. The @baseurl and other variable don't works because there are some relative paht like "../image" and in a transactionnal email I need to have the public absolute path for my image.
Is someone knoow how to do it please ?

I'am under Magento 2.3.4 community edition.

1 REPLY 1

Re: How to get image path from less file for email (offline) ?

Hello @Yohannento 

Please do try this, will help you out!

// File - lib/web/css/source/lib/_utilities.less
.lib-url(@_path) {
    @url: "@{baseDir}@{_path}";
}

.lib-url(
    @_path,
    @_module
) when not (@_module = false) and not (@_module = '') and (@urls-resolved = false) {
    @url: "@{_module}::@{_path}";
}

.lib-url(
    @_path,
    @_module
) when not (@_module = false) and not (@_module = '') and (@urls-resolved = true) {
    @url: "@{baseDir}@{_module}/@{_path}";
}

Thanks