Closed ghost closed 9 years ago
Same issue here. Also tried adding to hosts in .htaccess "localhost/mysite" still no luck.
Here's a couple lines of context (around line 590) followed by my workaround.
// ------------------------------------------------------------------------
// Load source of file and rewrite absolute URLs.
// ------------------------------------------------------------------------
$_css_src = file_get_contents($stylesheet['absolute_path']).PHP_EOL;
$_css_src = (!empty($_css_src)) ? Minify_CSS_UriRewriter::rewrite($_css_src, dirname($stylesheet['absolute_path']),wire('config')->paths->root) : $_css_src;
//SB: My fix for issue #30 about paths in css image urls. Compatible with Soma's fix for #20 in which you specify the path in css file starting with /site.
//Issue 30: When pw is installed in a subdirectory aiom omits the subdirectory from paths it makes for css image urls.
//Allows dev site's pw to be in doc root and deployed site's pw to be in subfolder (or the other way around) and have same css work on both.
//1. Specify image urls in css without any path (e.g. background:url(T-on75.jpg))
//2. Put the images in templates/styles/
$rel = str_replace($_SERVER['DOCUMENT_ROOT'], '', wire('config')->paths->templates); //relative path to templates from doc root. Maybe /subfolder/site/templates
$_css_src = str_replace('url(/site/templates/styles/', 'url(' . $rel . 'styles/', $_css_src); //processed url: /subfolder/site/templates/styles/T-off75.jpg
More elegant way to fix this is simply remove wire document root assumption and expect real DOCUMENT_ROOT to be replaced with Minify_CSS_UriRewriter::rewrite() method.
So simply:
Line 590:
$_css_src = (!empty($_css_src)) ? Minify_CSS_UriRewriter::rewrite($_css_src, dirname($stylesheet['absolute_path']),wire('config')->paths->root) : $_css_src;
To:
$_css_src = (!empty($_css_src)) ? Minify_CSS_UriRewriter::rewrite($_css_src, dirname($stylesheet['absolute_path'])) : $_css_src;
Fixes this issue, and all URL rewrites are done from DOCUMENT_ROOT instead of wire root
Thanks @Stikki is is a simple and cleaner solution.
Hello everybody,
sorry for my late response. I merged the solution of @Stikki. AIOM has been updated to version 3.1.5. Thank you for your report!
A issue with the path of the images into the css file when pw is installed in a subdirectory, example:
the correct file path output without AIOM+
http://localhost/mysite/site/templates/images/image.jpg
file path output with AIOM+ enable
http://localhost/site/templates/images/image.jpg
this generate 404 error, file not found.
I tried to fix changing the RewriteBase in .htaccess enabling my localhost subdirectory
RewriteBase /mysite/
but the same error still happens if I turn off the AIOM + and use the url from the css file works without any inconvenience..