#1046 Take the first enclosure of type 'image/jpg' to use as thumbnail
Merged 3 years ago by bcotton. Opened 3 years ago by vinaydeshmukh.
vinaydeshmukh/fedora-websites mag1045  into  master

@@ -20,6 +20,11 @@ 

          # removing '[...]' from the summary, so its cleaner

          summary = item.summary.rstrip(' […]').replace("’", "'").replace("&#8217", "'")

          item.title = item.title.replace("&", "&")

+         # find the first image enclosure

+         for image_enclosure in item.enclosures:

+             if image_enclosure['type'] == 'image/jpg':

+                 break

+ 

          html += """

          <div class="hidden-xs col-sm-1 top-margin">

  			<p class="month">%s</p>
@@ -44,7 +49,7 @@ 

          		</div>

          	</div>

  		</div>

-         """ % (item.updated.split()[2], item.updated.split()[1], item.enclosures[0].href.replace("&", "&#38;"), item.links[0]['href'], item.title,

+         """ % (item.updated.split()[2], item.updated.split()[1], image_enclosure.href.replace("&", "&#38;"), item.links[0]['href'], item.title,

  			item.slash_comments, summary, item.links[0]['href'])

  #print item.content

  #break

for start.fedoraprojectorg

This commit iterates over the enclosure tags of each article, and uses
the first one whose type attribute is 'image/jpg'.
In the case no enclosure with this criteria is found, it will use the
last enclosure in the list.

Fixes issue #1045

I tested this and can verify it works to solve the issue with broken image links from the magazine feed. Thanks @vinaydeshmukh for getting this done, you beat me to the solution!

@vinaydeshmukh I see you haven't completed the Fedora Project Contributor Agreement (FPCA). Would you mind doing that before I merge this? See the wiki for more information.

Metadata Update from @bcotton:
- Pull-request tagged with: start.fp.o

3 years ago

Metadata Update from @bcotton:
- Request assigned

3 years ago

@bcotton No, not at all. I've completed the FCPA now.

@jakfrost :D

Pull-Request has been merged by bcotton

3 years ago