mkdocs-ultralytics-plugin 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (16) hide show
  1. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/PKG-INFO +1 -1
  2. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/mkdocs_ultralytics_plugin.egg-info/PKG-INFO +1 -1
  3. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/plugin/__init__.py +1 -1
  4. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/plugin/processor.py +22 -10
  5. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/LICENSE +0 -0
  6. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/README.md +0 -0
  7. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/mkdocs_ultralytics_plugin.egg-info/SOURCES.txt +0 -0
  8. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/mkdocs_ultralytics_plugin.egg-info/dependency_links.txt +0 -0
  9. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/mkdocs_ultralytics_plugin.egg-info/entry_points.txt +0 -0
  10. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/mkdocs_ultralytics_plugin.egg-info/requires.txt +0 -0
  11. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/mkdocs_ultralytics_plugin.egg-info/top_level.txt +0 -0
  12. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/plugin/main.py +0 -0
  13. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/plugin/postprocess.py +0 -0
  14. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/plugin/utils.py +0 -0
  15. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/pyproject.toml +0 -0
  16. {mkdocs_ultralytics_plugin-0.2.0 → mkdocs_ultralytics_plugin-0.2.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-ultralytics-plugin
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: An MkDocs plugin that provides Ultralytics Docs customizations at https://docs.ultralytics.com.
5
5
  Author-email: Glenn Jocher <hello@ultralytics.com>
6
6
  Maintainer-email: Ultralytics <hello@ultralytics.com>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-ultralytics-plugin
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: An MkDocs plugin that provides Ultralytics Docs customizations at https://docs.ultralytics.com.
5
5
  Author-email: Glenn Jocher <hello@ultralytics.com>
6
6
  Maintainer-email: Ultralytics <hello@ultralytics.com>
@@ -1,6 +1,6 @@
1
1
  # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
2
 
3
- __version__ = "0.2.0"
3
+ __version__ = "0.2.1"
4
4
 
5
5
  from .main import MetaPlugin
6
6
  from .postprocess import postprocess_site
@@ -245,17 +245,29 @@ def process_html(
245
245
  if len(desc) >= 10:
246
246
  meta["description"] = desc
247
247
 
248
+ # ---------- IMAGE PICKING (body only, non-AVIF) ----------
248
249
  if add_image:
249
- if first_image := soup.find("img"):
250
- img_src = first_image.get("src", "")
251
- if img_src and (
252
- img_src.startswith(("http://", "https://", "/")) or not img_src.startswith(("javascript:", "data:"))
253
- ):
254
- meta["image"] = img_src
255
- elif youtube_ids := get_youtube_video_ids(soup):
256
- meta["image"] = f"https://img.youtube.com/vi/{youtube_ids[0]}/maxresdefault.jpg"
257
- elif default_image:
258
- meta["image"] = default_image
250
+ search_root = soup.find("article", class_="md-content__inner") or soup.body or soup
251
+
252
+ image_src: str | None = None
253
+ for img in search_root.find_all("img", src=True):
254
+ src = img["src"]
255
+ lower = src.lower()
256
+ if not lower or ".avif" in lower:
257
+ continue
258
+ if lower.startswith(("javascript:", "data:")):
259
+ continue
260
+ image_src = src
261
+ break
262
+
263
+ if not image_src and (youtube_ids := get_youtube_video_ids(soup)):
264
+ image_src = f"https://img.youtube.com/vi/{youtube_ids[0]}/maxresdefault.jpg"
265
+ if not image_src and default_image:
266
+ image_src = default_image
267
+
268
+ if image_src:
269
+ meta["image"] = image_src
270
+ # ---------------------------------------------------------
259
271
 
260
272
  # Add meta tags to head
261
273
  if not soup.find("meta", attrs={"name": "title"}):