bug fix for blogs without featured image
This commit is contained in:
@@ -679,11 +679,12 @@ def get_blog_posts(request):
|
||||
|
||||
|
||||
for postdata in blogs_json[0:3]:
|
||||
|
||||
try:
|
||||
featuredmedia = postdata['featured_media']
|
||||
url = 'https://analytics.rowsandall.com/wp-json/wp/v2/media/%d' % featuredmedia
|
||||
response = requests.get(url)
|
||||
|
||||
|
||||
if response.status_code == 200:
|
||||
image_json = response.json()
|
||||
image_url = image_json[
|
||||
@@ -695,6 +696,8 @@ def get_blog_posts(request):
|
||||
][
|
||||
'source_url'
|
||||
]
|
||||
else:
|
||||
image_url = ''
|
||||
except KeyError:
|
||||
image_url = ''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user