File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig:
123123 cache_dir = self .cache_dir ,
124124 use_git = self .config .use_git ,
125125 integration_material_social_cards = self .integration_material_social_cards ,
126+ mkdocs_command_is_on_serve = self .cmd_is_serve ,
126127 )
127128
128129 # check template dirs
Original file line number Diff line number Diff line change @@ -72,12 +72,13 @@ class Util:
7272
7373 def __init__ (
7474 self ,
75- path : str = "." ,
7675 cache_dir : Path = DEFAULT_CACHE_FOLDER ,
77- use_git : bool = True ,
7876 integration_material_social_cards : Optional [
7977 IntegrationMaterialSocialCards
8078 ] = None ,
79+ mkdocs_command_is_on_serve : bool = False ,
80+ path : str = "." ,
81+ use_git : bool = True ,
8182 ):
8283 """Class hosting the plugin logic.
8384
@@ -87,6 +88,13 @@ def __init__(
8788 integration_material_social_cards (bool, optional): option to enable
8889 integration with Social Cards plugin from Material theme. Defaults to True.
8990 """
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+
9098 if use_git :
9199 logger .debug ("Git use is enabled." )
92100 try :
@@ -654,6 +662,9 @@ def get_remote_image_length(
654662 Returns:
655663 int | None: image length as int or None
656664 """
665+ if self .mkdocs_command_is_on_serve :
666+ return None
667+
657668 # first, try HEAD request to avoid downloading the image
658669 try :
659670 attempt += 1
You can’t perform that action at this time.
0 commit comments