File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 5252 foreach (new RegexIterator ($ iterator , '/^.+\.html$/i ' , RegexIterator::GET_MATCH ) as $ match ) {
5353 $ htmlFilePath = array_shift ($ match );
5454 $ htmlContents = file_get_contents ($ htmlFilePath );
55- file_put_contents ($ htmlFilePath , str_replace ('<head> ' , '<head><base href="/"> ' , $ htmlContents ));
55+
56+ $ htmlRelativeFilePath = str_replace ($ outputDir .'/ ' , '' , $ htmlFilePath );
57+ $ subdirLevel = substr_count ($ htmlRelativeFilePath , '/ ' );
58+ $ baseHref = str_repeat ('../ ' , $ subdirLevel );
59+
60+ $ htmlContents = str_replace ('<head> ' , '<head><base href=" ' .$ baseHref .'"> ' , $ htmlContents );
61+ $ htmlContents = str_replace ('<img src="/_images/ ' , '<img src="_images/ ' , $ htmlContents );
62+ file_put_contents ($ htmlFilePath , $ htmlContents );
5663 }
5764
5865 foreach (new RegexIterator ($ iterator , '/^.+\.css/i ' , RegexIterator::GET_MATCH ) as $ match ) {
You can’t perform that action at this time.
0 commit comments