File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
pelican/plugins/featured_image Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ def images_extraction(instance):
3232 if not featured_image :
3333 soup = BeautifulSoup (instance ._content , "html.parser" )
3434 imageTag = soup .find ("img" )
35- if imageTag :
35+ if imageTag and imageTag . get ( "src" ) :
3636 featured_image = imageTag ["src" ]
3737
3838 # Set the attribute to content instance
Original file line number Diff line number Diff line change @@ -41,6 +41,22 @@ def test_extract_image_from_content(self):
4141 featured_image .images_extraction (article )
4242 self .assertEqual (article .featured_image , TEST_CONTENT_IMAGE_URL )
4343
44+ def test_extract_image_from_content_and_img_has_no_src (self ):
45+ args = {
46+ "content" : (
47+ str (generate_lorem_ipsum (n = 3 , html = True ))
48+ + "<img>"
49+ + str (generate_lorem_ipsum (n = 2 , html = True ))
50+ ),
51+ "metadata" : {
52+ "summary" : TEST_SUMMARY_WITHOUTIMAGE ,
53+ },
54+ }
55+
56+ article = Article (** args )
57+ featured_image .images_extraction (article )
58+ self .assertEqual (article .featured_image , None )
59+
4460 def test_extract_image_from_summary (self ):
4561 args = {
4662 "content" : TEST_CONTENT ,
You can’t perform that action at this time.
0 commit comments