Get image from page

28 views
Skip to first unread message

Ankhaa Tsogoo

unread,
Jun 15, 2013, 1:03:00 PM6/15/13
to mezzani...@googlegroups.com
How can i get a first image from page content . In other words from richtext page?

Josh Cartmell

unread,
Jun 16, 2013, 11:55:57 PM6/16/13
to mezzani...@googlegroups.com
I would probably connect to the post save signal for RichTextPages and then use something like http://www.crummy.com/software/BeautifulSoup/ to parse the html and pull out the first img tag.

Let us know how it goes!


On Sat, Jun 15, 2013 at 10:03 AM, Ankhaa Tsogoo <ankha...@gmail.com> wrote:
How can i get a first image from page content . In other words from richtext page?

--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Ankhaa Tsogoo

unread,
Jun 19, 2013, 3:02:39 AM6/19/13
to mezzani...@googlegroups.com
As you said i looked into bs4. But how should i connect to post and save signal? Could you give me some advice?

Josh Cartmell

unread,
Jun 19, 2013, 12:17:28 PM6/19/13
to mezzani...@googlegroups.com
It's nothing specific to Mezzanine, here is the Django documentation on the post_save signal that I think you would want to use:
https://docs.djangoproject.com/en/dev/ref/signals/#post-save
and here is an example of how to use it:
http://www.djangofoo.com/tag/post_save

Depending on what you are doing you may want to connect to the pre_save rather than the post_save
Reply all
Reply to author
Forward
0 new messages