Example #1
0
 public function prefixResourceUrls($prefix)
 {
     foreach (phpQuery::pq('a, img', $this->doc) as $node) {
         HtmlUtils::prefixNodeAttrs($node, 'src,href,srcset', $prefix, function ($url) {
             return Utils::isResourceUrl($url);
         });
     }
 }
Example #2
0
 function test_prefixNodeAttrs()
 {
     $doc = phpQuery::newDocument('<img src="img0.jpg" srcset="img1.jpg 1000w, img2.jpg" href="link.html"/>');
     $img = phpQuery::pq('img', $doc)->elements[0];
     $img = HtmlUtils::prefixNodeAttrs($img, 'src, srcset,href,dummy', 'p1/');
     $this->assertEquals('p1/img0.jpg', $img->getAttribute('src'));
     $this->assertEquals('p1/img1.jpg 1000w, p1/img2.jpg', $img->getAttribute('srcset'));
     $this->assertEquals('p1/link.html', $img->getAttribute('href'));
 }