mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Max length for image_urls.
This commit is contained in:
parent
d96bbf7f66
commit
0f48e88681
2 changed files with 15 additions and 0 deletions
|
@ -2803,6 +2803,14 @@ class MStory(mongo.Document):
|
|||
if len(image_urls):
|
||||
self.image_urls = [u for u in image_urls if u]
|
||||
|
||||
max_length = MStory.image_urls.field.max_length
|
||||
while len(''.join(self.image_urls)) > max_length:
|
||||
if len(self.image_urls) <= 1:
|
||||
self.image_urls[0] = self.image_urls[0][:max_length-1]
|
||||
break
|
||||
else:
|
||||
self.image_urls.pop()
|
||||
|
||||
return self.image_urls
|
||||
|
||||
def fetch_original_text(self, force=False, request=None, debug=False):
|
||||
|
|
|
@ -2302,6 +2302,13 @@ class MSharedStory(mongo.DynamicDocument):
|
|||
image_sources = [img.get('src') for img in soup.findAll('img') if img and img.get('src')]
|
||||
if len(image_sources) > 0:
|
||||
self.image_urls = image_sources
|
||||
max_length = MSharedStory.image_urls.field.max_length
|
||||
while len(''.join(self.image_urls)) > max_length:
|
||||
if len(self.image_urls) <= 1:
|
||||
self.image_urls[0] = self.image_urls[0][:max_length-1]
|
||||
break
|
||||
else:
|
||||
self.image_urls.pop()
|
||||
self.save()
|
||||
|
||||
def calculate_image_sizes(self, force=False):
|
||||
|
|
Loading…
Add table
Reference in a new issue