Commit 75a7ced1 authored by Michael Strelan's avatar Michael Strelan Committed by Derek Wright
Browse files

Issue #2993935 by mstrelan, dww: Support for srcset attribute

parent af6d2bbe
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -106,11 +106,11 @@ function _pathologic_filter($text, $settings, $hash) {
  $cached_settings['current_settings'] = &$cached_settings[$hash];

  // Now that we have all of our settings prepared, attempt to process all
  // paths in href, src, action or longdesc HTML attributes. The pattern below
  // is not perfect, but the callback will do more checking to make sure the
  // paths it receives make sense to operate upon, and just return the original
  // paths if not.
  return preg_replace_callback('~ (href|src|action|longdesc)="([^"]+)~i', '_pathologic_replace', $text);
  // paths in href, src, srcset, action or longdesc HTML attributes. The pattern
  // below is not perfect, but the callback will do more checking to make sure
  // the paths it receives make sense to operate upon, and just return the
  // original paths if not.
  return preg_replace_callback('~ (href|src|srcset|action|longdesc)="([^"]+)~i', '_pathologic_replace', $text);
}

/**
+2 −2
Original line number Diff line number Diff line
@@ -197,8 +197,8 @@ class PathologicTest extends BrowserTestBase {
      t('Path Filter compatibility (files:)')
    );
    $this->assertEqual(
      check_markup('<a href="http://example.com/qux/foo"><img src="http://example.org/bar.jpeg" longdesc="/bananas/baz" /></a>', $format_id),
      '<a href="' . _pathologic_content_url('foo', ['absolute' => TRUE]) . '"><img src="' . _pathologic_content_url('bar.jpeg', ['absolute' => TRUE]) . '" longdesc="' . _pathologic_content_url('baz', ['absolute' => TRUE]) . '" /></a>',
      check_markup('<a href="http://example.com/qux/foo"><picture><source srcset="http://example.org/bar.jpeg" /><img src="http://example.org/bar.jpeg" longdesc="/bananas/baz" /></picture></a>', $format_id),
      '<a href="' . _pathologic_content_url('foo', ['absolute' => TRUE]) . '"><picture><source srcset="' . _pathologic_content_url('bar.jpeg', ['absolute' => TRUE]) . '" /><img src="' . _pathologic_content_url('bar.jpeg', ['absolute' => TRUE]) . '" longdesc="' . _pathologic_content_url('baz', ['absolute' => TRUE]) . '" /></picture></a>',
      t('"All base paths for this site" functionality')
    );
    $this->assertEqual(