Extract CSS Paths


/ Published in: JavaScript
Save to your folder(s)

Returns an array of all URL image paths to assist in saving all assets from CSS


Copy this code and paste it in your HTML
  1. function extractCssPaths(css) {
  2. var results = css.match(/url\(['"]?[^\s]*['|"]?\)/g);
  3. for (var i = 0, max = results.length; i < max; i++) {
  4. results[i] = results[i].replace(/url\(/, '');
  5. results[i] = results[i].replace(/['|"]/g, '');
  6. results[i] = results[i].replace(/\)/, '');
  7. }
  8. return results;
  9. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.