fix: VPC image scraping and show species name on plant edit
- vpc.py: target .wp-caption img for hero image (VPC uses Elementor, not standard WooCommerce gallery); skip logo and placeholder images by URL pattern - plant_edit view: pass plant.species as 'species' so the species info banner (including scientific name) appears on the edit form Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
7fef359ae0
commit
a48ee9e73d
2 changed files with 6 additions and 4 deletions
|
|
@ -151,12 +151,13 @@ def scrape_plant(slug):
|
|||
h1 = soup.find('h1')
|
||||
name = h1.get_text(strip=True) if h1 else slug.replace('-', ' ').title()
|
||||
|
||||
# Hero image
|
||||
# Hero image — VPC wraps the plant photo in a .wp-caption figure
|
||||
hero_img = ''
|
||||
for sel in ['.woocommerce-product-gallery img', '.product-images img', 'article img']:
|
||||
for sel in ['.wp-caption img', 'figure img', '.elementor-widget-image img']:
|
||||
img = soup.select_one(sel)
|
||||
if img and img.get('src', '').startswith('http'):
|
||||
hero_img = img['src']
|
||||
src = img.get('src', '') if img else ''
|
||||
if src.startswith('http') and 'Grif_VPC' not in src and 'NoImage' not in src:
|
||||
hero_img = src
|
||||
break
|
||||
|
||||
result = {
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ def plant_edit(request, pk):
|
|||
return render(request, 'plants/plant_form.html', {
|
||||
'form': form,
|
||||
'plant': plant,
|
||||
'species': plant.species,
|
||||
'title': 'Edit Plant',
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue