wro4j-core/src/main/java/ro/isdc/wro/model/resource/processor/impl/css/CssDataUriPreProcessor.java
@Override
  protected String replaceImageUrl(final String cssUri, final String imageUrl) {
    Validate.notNull(uriLocatorFactory);
    LOG.debug("replace url for image: {} from css: {}", imageUrl, cssUri);
    final String cleanImageUrl = cleanImageUrl(imageUrl);
    final String fileName = FilenameUtils.getName(imageUrl);
    String fullPath = cleanImageUrl;
    /**
     * Allow dataUri transformation of absolute url's using http(s) protocol. All url's protocol are intentionally not
     * allowed, because it could be a potential security issue. For instance:
     *
     * <pre>
     * .class {
     *   background: url(file:/path/to/secure/file.png);
     * }
     * </pre>
     *
     * This should not be allowed.
     */
    if (isImageUrlChangeRequired(cleanImageUrl)) {
      fullPath = WroUtil.getFullPath(cssUri) + cleanImageUrl;
    }
    String result = imageUrl;
    InputStream is = null;
    try {
      is = uriLocatorFactory.locate(fullPath);
      final String dataUri = getDataUriGenerator().generateDataURI(is, fileName);
      if (isReplaceAccepted(dataUri)) {
        result = dataUri;
        LOG.debug("dataUri replacement: {}", StringUtils.abbreviate(dataUri, 30));
      }
    } catch (final IOException e) {
      LOG.warn("[FAIL] extract dataUri from: {}, because: {}. "
          + "A possible cause: using CssUrlRewritingProcessor before CssDataUriPreProcessor.", fullPath, e.getMessage());
    } finally {
      IOUtils.closeQuietly(is);
    }
    return result;
  }
@Override
  protected String replaceImageUrl(final String cssUri, final String imageUrl) {
    Validate.notNull(uriLocatorFactory);
    LOG.debug("replace url for image: {} from css: {}", imageUrl, cssUri);
    final String cleanImageUrl = cleanImageUrl(imageUrl);
    final String fileName = FilenameUtils.getName(imageUrl);
    String fullPath = cleanImageUrl;
    /**
     * Allow dataUri transformation of absolute url's using http(s) protocol. All url's protocol are intentionally not
     * allowed, because it could be a potential security issue. For instance:
     *
     * <pre>
     * .class {
     *   background: url(file:/path/to/secure/file.png);
     * }
     * </pre>
     *
     * This should not be allowed.
     */
    if (isImageUrlChangeRequired(cleanImageUrl)) {
      fullPath = WroUtil.getFullPath(cssUri) + cleanImageUrl;
    }
    String result = imageUrl;
    InputStream is = null;
    try {
      is = uriLocatorFactory.locate(fullPath);
      final String dataUri = getDataUriGenerator().generateDataURI(is, fileName);
      if (isReplaceAccepted(dataUri)) {
        result = dataUri;
        LOG.debug("dataUri replacement: {}", StringUtils.abbreviate(dataUri, 30));
      }
    } catch (final IOException e) {
      LOG.warn("[FAIL] extract dataUri from: {}, because: {}. "
          + "A possible cause: using CssUrlRewritingProcessor before CssDataUriPreProcessor.", fullPath, e.getMessage());
    } finally {
      IOUtils.closeQuietly(is);
    }
    return result;
  }
@ Override protected String replaceImageUrl ( final String cssUri , final String imageUrl ) { Validate . notNull ( uriLocatorFactory ) ; LOG . debug ( "replace url for image: {} from css: {}" , imageUrl , cssUri ) ; final String cleanImageUrl = cleanImageUrl ( imageUrl ) ; final String fileName = FilenameUtils . getName ( imageUrl ) ; String fullPath = cleanImageUrl ; /**
     * Allow dataUri transformation of absolute url's using http(s) protocol. All url's protocol are intentionally not
     * allowed, because it could be a potential security issue. For instance:
     *
     * <pre>
     * .class {
     *   background: url(file:/path/to/secure/file.png);
     * }
     * </pre>
     *
     * This should not be allowed.
     */ if ( isImageUrlChangeRequired ( cleanImageUrl ) ) { fullPath = WroUtil . getFullPath ( cssUri ) + cleanImageUrl ; } String result = imageUrl ; InputStream is = null ; try { is = uriLocatorFactory . locate ( fullPath ) ; final String dataUri = getDataUriGenerator ( ) . generateDataURI ( is , fileName ) ; if ( isReplaceAccepted ( dataUri ) ) { result = dataUri ; LOG . debug ( "dataUri replacement: {}" , StringUtils . abbreviate ( dataUri , 30 ) ) ; } } catch ( final IOException e ) { LOG . warn ( "[FAIL] extract dataUri from: {}, because: {}. " + "A possible cause: using CssUrlRewritingProcessor before CssDataUriPreProcessor." , fullPath , e . getMessage ( ) ) ; } finally { IOUtils . closeQuietly ( is ) ; } return result ; }
Replace provided url with the new url if needed.

@param imageUrl
to replace.
@param cssUri
Uri of the parsed css.
@return replaced url.
Replace provided url with the new url if needed .