File tree Expand file tree Collapse file tree 4 files changed +34
-6
lines changed
fixtures/expected/main/form Expand file tree Collapse file tree 4 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public function __construct()
3737 $ this ->theme = Configuration::THEME_DEFAULT ;
3838 $ this ->symfonyVersion = '4.4 ' ;
3939 $ this ->excludedPaths = [];
40- $ this ->imagesPublicPrefix = '/_images ' ;
40+ $ this ->imagesPublicPrefix = '' ;
4141 }
4242
4343 public function createFileFinder (): Finder
Original file line number Diff line number Diff line change @@ -53,7 +53,11 @@ public function preNodeRender(PreNodeRenderEvent $event)
5353 $ newAbsoluteFilePath = $ this ->buildConfig ->getImagesDir ().'/ ' .$ fileInfo ->getFilename ();
5454 $ fs ->copy ($ sourceImage , $ newAbsoluteFilePath , true );
5555
56- $ newUrlPath = $ this ->buildConfig ->getImagesPublicPrefix ().'/ ' .$ fileInfo ->getFilename ();
57- $ node ->setValue ($ node ->getEnvironment ()->relativeUrl ($ newUrlPath ));
56+ if ('' === $ this ->buildConfig ->getImagesPublicPrefix ()) {
57+ $ newUrlPath = $ node ->getEnvironment ()->relativeUrl ('_images/ ' .$ fileInfo ->getFilename ());
58+ } else {
59+ $ newUrlPath = $ this ->buildConfig ->getImagesPublicPrefix ().'/ ' .$ fileInfo ->getFilename ();
60+ }
61+ $ node ->setValue ($ newUrlPath );
5862 }
5963}
Original file line number Diff line number Diff line change @@ -90,6 +90,30 @@ public function testBuildDocsForPdf()
9090 $ this ->assertStringContainsString ('[OK] Build complete ' , $ output );
9191 }
9292
93+ public function testBuildDocsWithCustomImagePrefix ()
94+ {
95+ $ buildConfig = $ this ->createBuildConfig ();
96+ $ buildConfig ->setImagesPublicPrefix ('/some/custom/prefix-for-images ' );
97+ $ outputDir = __DIR__ .'/../_output ' ;
98+
99+ $ filesystem = new Filesystem ();
100+ $ filesystem ->remove ($ outputDir );
101+ $ filesystem ->mkdir ($ outputDir );
102+
103+ $ output = $ this ->executeCommand (
104+ $ buildConfig ,
105+ [
106+ 'source-dir ' => __DIR__ .'/../fixtures/source/main ' ,
107+ 'output-dir ' => $ outputDir ,
108+ ]
109+ );
110+
111+ $ this ->assertStringContainsString ('[OK] Build complete ' , $ output );
112+
113+ $ generatedHtml = file_get_contents ($ outputDir .'/index.html ' );
114+ $ this ->assertStringContainsString ('/some/custom/prefix-for-images/symfony-logo.png ' , $ generatedHtml );
115+ }
116+
93117 private function executeCommand (BuildConfig $ buildConfig , array $ input ): string
94118 {
95119 $ input ['--no-theme ' ] = true ;
Original file line number Diff line number Diff line change 33 < head >
44 < meta charset ="utf-8 " />
55
6-
6+
77 </ head >
88
99 < body >
1010 < div class ="section ">
1111< h1 id ="formtype-documentation "> < a class ="headerlink " href ="#formtype-documentation " title ="Permalink to this headline "> FormType Documentation</ a > </ h1 >
1212< span id ="internal-reference "> </ span >
13- < img src ="../ _images/symfony-logo.png " />
13+ < img src ="_images/symfony-logo.png " />
1414</ div >
1515
1616 </ body >
17- </ html >
17+ </ html >
You can’t perform that action at this time.
0 commit comments