├── LICENSE.txt ├── README.md ├── app ├── code │ └── community │ │ └── JustBetter │ │ └── CssMergeDataUriFix │ │ ├── Model │ │ └── Design │ │ │ └── Package.php │ │ └── etc │ │ └── config.xml └── etc │ └── modules │ └── JustBetter_CssMergeDataUriFix.xml └── modman /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 JustBetter 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Magento 1 CSS Merge Data URI Fix 2 | 3 | This module fixes a bug which is present in all Magento 1 versions which case a corrupt CSS file when Magento's default CSS merging functionality is activated and data URI's are used in the CSS, for example with inline images. For more information see: http://magento.stackexchange.com/questions/14973/problem-with-data-uris-and-css-file-merge 4 | 5 | ## Why doesn't Magento fix this? 6 | 7 | It's a known issue but probably they focus more on Magento 2, understandable. 8 | 9 | ## Installation 10 | 11 | * Use [modman](https://github.com/colinmollenhour/modman): `modman clone https://github.com/justbetter/magento1-css-merge-data-uri-fix.git` 12 | * Manually: [download](https://github.com/justbetter/magento1-css-merge-data-uri-fix/archive/master.zip), unzip and copy. 13 | 14 | ## Compability 15 | This module overrides just one Magento model and is compatible with [our cache buster module](https://github.com/justbetter/magento1-cache-buster) which overrides the same model. It's tested on Magento 1.9.3.7 but should work on every older version. 16 | 17 | ## Ideas, bugs or suggestions? 18 | Please create a [issue](https://github.com/justbetter/magento1-css-merge-data-uri-fix/issues) or a [pull request](https://github.com/justbetter/magento1-css-merge-data-uri-fix/pulls). 19 | 20 | ## License 21 | [MIT](LICENSE.txt) 22 | 23 | ## About us 24 | We’re a innovative development agency from The Netherlands building awesome websites, webshops and web applications with Laravel and Magento. Check out our website [justbetter.nl](https://justbetter.nl) and our [open source projects](https://github.com/justbetter). 25 | 26 | --- 27 | 28 | JustBetter logo 29 | -------------------------------------------------------------------------------- /app/code/community/JustBetter/CssMergeDataUriFix/Model/Design/Package.php: -------------------------------------------------------------------------------- 1 | _setCallbackFileDir($file); 7 | 8 | $cssImport = '/@import\\s+([\'"])(.*?)[\'"]/'; 9 | $contents = preg_replace_callback($cssImport, array($this, '_cssMergerImportCallback'), $contents); 10 | 11 | $cssUrl = '/url\\(\\s*(?![\\\'\\"]?data:)([^\\)\\s]+)\\s*\\)?/'; 12 | $contents = preg_replace_callback($cssUrl, array($this, '_cssMergerUrlCallback'), $contents); 13 | 14 | return $contents; 15 | } 16 | } 17 | 18 | // JustBetter_CacheBuster module compatiblity 19 | if (Mage::helper('core')->isModuleEnabled('JustBetter_CacheBuster')) { 20 | class JustBetter_CssMergeDataUriFix_Model_Design_Package extends JustBetter_CacheBuster_Model_Design_Package { 21 | use JustBetter_CssMergeDataUriFix; 22 | } 23 | } else { 24 | class JustBetter_CssMergeDataUriFix_Model_Design_Package extends Mage_Core_Model_Design_Package { 25 | use JustBetter_CssMergeDataUriFix; 26 | } 27 | } -------------------------------------------------------------------------------- /app/code/community/JustBetter/CssMergeDataUriFix/etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 1.0.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | JustBetter_CssMergeDataUriFix_Model_Design_Package 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/etc/modules/JustBetter_CssMergeDataUriFix.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | community 7 | 8 | 9 | -------------------------------------------------------------------------------- /modman: -------------------------------------------------------------------------------- 1 | app/code/community/JustBetter/CssMergeDataUriFix/ app/code/community/JustBetter/CssMergeDataUriFix/ 2 | app/etc/modules/JustBetter_CssMergeDataUriFix.xml app/etc/modules/JustBetter_CssMergeDataUriFix.xml --------------------------------------------------------------------------------