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.
<style>
.example {
background-image: url("/images/example.png");
}
</style>
<style>
.example {
background-image: url("images/example.png");
}
</style>
Joomla 3.9
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.
Title |
|
||||||
Labels |
Added:
?
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-02-20 11:26:49 |
Closed_By | ⇒ | brianteeman |
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.
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');
}
");
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>
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).
Status | Closed | ⇒ | New |
Closed_Date | 2020-02-20 11:26:49 | ⇒ | |
Closed_By | brianteeman | ⇒ |
Status | New | ⇒ | Confirmed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ |
Set to "open" on behalf of @SharkyKZ by The JTracker Application at issues.joomla.org/joomla-cms/27988
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
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: ? |
you should do something like this instaed
<style>
body {
background-image :url(<?php JURI::root(true); ?>/images/headers/blue-flower.jpg);
}
</style>
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.