File tree 4 files changed +34
-6
lines changed
fixtures/expected/main/form
4 files changed +34
-6
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public function __construct()
37
37
$ this ->theme = Configuration::THEME_DEFAULT ;
38
38
$ this ->symfonyVersion = '4.4 ' ;
39
39
$ this ->excludedPaths = [];
40
- $ this ->imagesPublicPrefix = '/_images ' ;
40
+ $ this ->imagesPublicPrefix = '' ;
41
41
}
42
42
43
43
public function createFileFinder (): Finder
Original file line number Diff line number Diff line change @@ -53,7 +53,11 @@ public function preNodeRender(PreNodeRenderEvent $event)
53
53
$ newAbsoluteFilePath = $ this ->buildConfig ->getImagesDir ().'/ ' .$ fileInfo ->getFilename ();
54
54
$ fs ->copy ($ sourceImage , $ newAbsoluteFilePath , true );
55
55
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 );
58
62
}
59
63
}
Original file line number Diff line number Diff line change @@ -90,6 +90,30 @@ public function testBuildDocsForPdf()
90
90
$ this ->assertStringContainsString ('[OK] Build complete ' , $ output );
91
91
}
92
92
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
+
93
117
private function executeCommand (BuildConfig $ buildConfig , array $ input ): string
94
118
{
95
119
$ input ['--no-theme ' ] = true ;
Original file line number Diff line number Diff line change 3
3
< head >
4
4
< meta charset ="utf-8 " />
5
5
6
-
6
+
7
7
</ head >
8
8
9
9
< body >
10
10
< div class ="section ">
11
11
< h1 id ="formtype-documentation "> < a class ="headerlink " href ="#formtype-documentation " title ="Permalink to this headline "> FormType Documentation</ a > </ h1 >
12
12
< span id ="internal-reference "> </ span >
13
- < img src ="../ _images/symfony-logo.png " />
13
+ < img src ="_images/symfony-logo.png " />
14
14
</ div >
15
15
16
16
</ body >
17
- </ html >
17
+ </ html >
You can’t perform that action at this time.
0 commit comments