Iam trying to extract image from content, with beautifulsoup or python or anything.
I tried using python goose but I'm not getting much help for this so I'm thinking to switch my tool to achieve this job.
I'm using wyswyg editor named django-ckeditor.
users make content through this editor which is being saved as a content field in my Post model. To display that, all I had to do was {{post.content}}
content users can post are image and text.
Now I want to display the image separately from the content. I want to thumbnail the image that's in content.
I used python goose to achieve this as I have some experience with this. I'm not sure why it's not working this time.
Here's my code
from django.db import models
from ckeditor_uploader.fields import RichTextUploadingField
class Post(models.Model):
title = models.CharField(max_length = 100)
content = RichTextUploadingField(config_name='default')
@property
def thumbnail(self, content):
g = Goose()
thumbnail = g.extract(raw_html=self.content).top_image.src
return thumbnail
in html file
<img src="{{ post.thumbnail }}" />
nothing shows up.
How do I extract images from the content?