|
13 | 13 | use Hyde\Framework\Exceptions\FileNotFoundException;
|
14 | 14 | use Hyde\Markdown\Contracts\FrontMatter\SubSchemas\FeaturedImageSchema;
|
15 | 15 |
|
| 16 | +use function in_array; |
16 | 17 | use function array_key_exists;
|
17 | 18 | use function array_flip;
|
18 | 19 | use function file_exists;
|
@@ -224,15 +225,20 @@ protected function getContentLengthForLocalImage(): int
|
224 | 225 |
|
225 | 226 | protected function getContentLengthForRemoteImage(): int
|
226 | 227 | {
|
227 |
| - $headers = Http::withHeaders([ |
228 |
| - 'User-Agent' => Config::getString('hyde.http_user_agent', 'RSS Request Client'), |
229 |
| - ])->head($this->getSource())->headers(); |
| 228 | + // TODO: We may want to globalize this check in the config, but for now, |
| 229 | + // we just check the server arguments and skip remote requests if |
| 230 | + // the --no-api flag is present (in the build command call) |
| 231 | + if (! (isset($_SERVER['argv']) && in_array('--no-api', $_SERVER['argv'], true))) { |
| 232 | + $headers = Http::withHeaders([ |
| 233 | + 'User-Agent' => Config::getString('hyde.http_user_agent', 'RSS Request Client'), |
| 234 | + ])->head($this->getSource())->headers(); |
230 | 235 |
|
231 |
| - if (array_key_exists('Content-Length', $headers)) { |
232 |
| - return (int) key(array_flip($headers['Content-Length'])); |
233 |
| - } |
| 236 | + if (array_key_exists('Content-Length', $headers)) { |
| 237 | + return (int) key(array_flip($headers['Content-Length'])); |
| 238 | + } |
234 | 239 |
|
235 |
| - BuildWarnings::report('The image "'.$this->getSource().'" has a content length of zero.'); |
| 240 | + BuildWarnings::report('The image "'.$this->getSource().'" has a content length of zero.'); |
| 241 | + } |
236 | 242 |
|
237 | 243 | return 0;
|
238 | 244 | }
|
|
0 commit comments