No Code Attached Yet
avatar LittleToni
LittleToni
19 Feb 2020

Steps to reproduce the issue

Insert the following HTML code to your template:

<style>
  .example {
    background-image: url("images/example.png");
  }
</style>

Show the page with SEF feature on and check the source code.

Expected result

<style>
  .example {
    background-image: url("/images/example.png");
  }
</style>

Actual result

<style>
  .example {
    background-image: url("images/example.png");
  }
</style>

System information (as much as possible)

Joomla 3.9

Additional comments

SEF Plugin doesn't check the described case using "background-image" in <style>-Tag. The Plugin checks only usage of "background-image" as inline css.

avatar LittleToni LittleToni - open - 19 Feb 2020
avatar joomla-cms-bot joomla-cms-bot - change - 19 Feb 2020
Title
[3.9] Background-Image Link is broken in <style>-Tag when SEF is on
[3.9] Background-Image Link is broken in -Tag when SEF is on
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 19 Feb 2020
avatar LittleToni LittleToni - change - 19 Feb 2020
The description was changed
avatar LittleToni LittleToni - edited - 19 Feb 2020
avatar brianteeman
brianteeman - comment - 20 Feb 2020

Sorry you are mistaken in your expectation. The expected behaviour is that the code you entered is the code that is used. That's exactly what is happening.

avatar brianteeman brianteeman - close - 20 Feb 2020
avatar brianteeman brianteeman - change - 20 Feb 2020
Status New Closed
Closed_Date 0000-00-00 00:00:00 2020-02-20 11:26:49
Closed_By brianteeman
avatar LittleToni
LittleToni - comment - 20 Feb 2020

An example for comparison. If you insert the following HTML code to your template:

<div style="background-image: url("images/example.png");">
  Example
</div>

Result

<div style="background-image: url("/images/example.png");">
  Example
</div>

The expected behaviour is that the code you entered is the code that is used. That's not the case.

avatar infograf768
infograf768 - comment - 20 Feb 2020

If the image is in the main images folder, the code should be
background-image: url("../images/example.png");

If it is in the template image folder, try

$this->addStyleDeclaration("
  	.example {
    	  	background-image: url('" . JURI::root(true) . "/templates/nameofmytemplate/images/example.png');
  	}
");
avatar LittleToni
LittleToni - comment - 20 Feb 2020

I insert Image URL with PHP from Custom Joomla Module (field type Media). This field type automatic makes the URL looks like "images/example.png".

Your Suggestion is ok but tell me a reason why the sef plugin checks case like:

<div style="background-image: url("images/example.png");">
  Example
</div>

but not case like:

<style>
  .example {
    background-image: url("images/example.png");
  }
</style>
avatar SharkyKZ
SharkyKZ - comment - 26 Feb 2020

If you use PHP to add images, you can add the base path yourself. However, I think this is a valid issue. It probably dates back to when <style> tags were only valid when used in <head> (before HTML5).

avatar joomla-cms-bot joomla-cms-bot - edited - 26 Feb 2020
avatar joomla-cms-bot joomla-cms-bot - change - 26 Feb 2020
Status Closed New
Closed_Date 2020-02-20 11:26:49
Closed_By brianteeman
avatar SharkyKZ SharkyKZ - change - 26 Feb 2020
Status New Confirmed
Closed_Date 0000-00-00 00:00:00
avatar joomla-cms-bot joomla-cms-bot - reopen - 26 Feb 2020
avatar joomla-cms-bot
joomla-cms-bot - comment - 26 Feb 2020
avatar brianteeman
brianteeman - comment - 27 Aug 2022

Thank you for raising this issue.

Joomla 3 is now in security only mode with no further bug fixes or new features.

As this issue doesn't relate to Joomla 4 it will now been closed.

If we are mistaken and this does apply to Joomla 4 please open a new issue (and reference this one if you wish) with updated details for testing in Joomla 4.
cc @zero-24

avatar alikon alikon - change - 28 Aug 2022
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2022-08-28 05:01:42
Closed_By alikon
Labels Added: No Code Attached Yet
Removed: ?
avatar alikon alikon - close - 28 Aug 2022
avatar bembelimen
bembelimen - comment - 29 Aug 2022

My code in template:
grafik

Calling home:
grafik

Calling a sub menu:
grafik

avatar alikon
alikon - comment - 29 Aug 2022

you should do something like this instaed

<style>
    body {
      background-image :url(<?php JURI::root(true); ?>/images/headers/blue-flower.jpg);
    }
  </style>

Add a Comment

Login with GitHub to post a comment