File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig:
123
123
cache_dir = self .cache_dir ,
124
124
use_git = self .config .use_git ,
125
125
integration_material_social_cards = self .integration_material_social_cards ,
126
+ mkdocs_command_is_on_serve = self .cmd_is_serve ,
126
127
)
127
128
128
129
# check template dirs
Original file line number Diff line number Diff line change @@ -72,12 +72,13 @@ class Util:
72
72
73
73
def __init__ (
74
74
self ,
75
- path : str = "." ,
76
75
cache_dir : Path = DEFAULT_CACHE_FOLDER ,
77
- use_git : bool = True ,
78
76
integration_material_social_cards : Optional [
79
77
IntegrationMaterialSocialCards
80
78
] = None ,
79
+ mkdocs_command_is_on_serve : bool = False ,
80
+ path : str = "." ,
81
+ use_git : bool = True ,
81
82
):
82
83
"""Class hosting the plugin logic.
83
84
@@ -87,6 +88,13 @@ def __init__(
87
88
integration_material_social_cards (bool, optional): option to enable
88
89
integration with Social Cards plugin from Material theme. Defaults to True.
89
90
"""
91
+ self .mkdocs_command_is_on_serve = mkdocs_command_is_on_serve
92
+ if self .mkdocs_command_is_on_serve :
93
+ logger .debug (
94
+ "Mkdocs serve - Fetching remote images length is disabled to avoid "
95
+ "HTTP errors."
96
+ )
97
+
90
98
if use_git :
91
99
logger .debug ("Git use is enabled." )
92
100
try :
@@ -654,6 +662,9 @@ def get_remote_image_length(
654
662
Returns:
655
663
int | None: image length as int or None
656
664
"""
665
+ if self .mkdocs_command_is_on_serve :
666
+ return None
667
+
657
668
# first, try HEAD request to avoid downloading the image
658
669
try :
659
670
attempt += 1
You can’t perform that action at this time.
0 commit comments