diff --git a/app/assets/stylesheets/common/foundation/mixins.scss b/app/assets/stylesheets/common/foundation/mixins.scss index 28c6b807c49..5a5d79ae5d2 100644 --- a/app/assets/stylesheets/common/foundation/mixins.scss +++ b/app/assets/stylesheets/common/foundation/mixins.scss @@ -200,7 +200,12 @@ $breakpoints: ( // it returns a CDN or subfolder path (if applicable). // SCSS will compile (and return the relative path) if public_image_path is missing. @if variable-exists(public_image_path) { - @return url("#{$public_image_path}#{$path}"); + @if (str-index("#{$path}", "/plugins") == 1) { + $plugin_asset_path: str-replace($public_image_path, "/images", ""); + @return url("#{$plugin_asset_path}#{$path}"); + } @else { + @return url("#{$public_image_path}#{$path}"); + } } @else { @return url("#{$path}"); } diff --git a/spec/components/stylesheet/compiler_spec.rb b/spec/components/stylesheet/compiler_spec.rb index 4e91d109b32..2c7dff02da4 100644 --- a/spec/components/stylesheet/compiler_spec.rb +++ b/spec/components/stylesheet/compiler_spec.rb @@ -118,6 +118,16 @@ describe Stylesheet::Compiler do expect(css).not_to include('absolute-image-url') end + it "supports absolute-image-url in plugins" do + set_cdn_url "https://awesome.com" + scss = Stylesheet::Importer.new({}).prepended_scss + scss += ".body{background-image: absolute-image-url('/plugins/discourse-special/images/somefile.png');}" + css, _map = Stylesheet::Compiler.compile(scss, "discourse-special.scss") + + expect(css).to include('url("https://awesome.com/plugins/discourse-special/images/somefile.png")') + expect(css).not_to include('absolute-image-url') + end + context "with a color scheme" do it "returns the default color definitions when no color scheme is specified" do css, _map = Stylesheet::Compiler.compile_asset("color_definitions")