Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extracting image from the content in my db #253

Open
lip365 opened this issue Feb 3, 2016 · 0 comments
Open

extracting image from the content in my db #253

lip365 opened this issue Feb 3, 2016 · 0 comments

Comments

@lip365
Copy link

lip365 commented Feb 3, 2016

Hello I'm trying to extract image from the content my user posts. (I know it sounds little bit odd)
I'm using wyswyg editor, django-ckeditor and when user posts text with images they are grouped as content. So to display the content(image and text), I do {{post.content}}. But I want to thumbnail an image in the front page, if there's an image in context. So I'm trying to extract image from the content in my db.
This is my try,


from goose import Goose

class Post(models.Model):
    content = RichTextUploadingField(config_name='default')
    @property

    def thumbnail(self, content):
        g = Goose()
        thumbnail = g.extract(raw_html=self.content).top_image.src
        return thumbnail

to display the image,
I did <img src = "{{post.thumbnail}}" />but nothing shows up. no error, no image.
Is it possible to do the following feature with python goose? am I doing it wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant