[COREblog-en] Modified Coreblog with nice features
Luistxo Fernandez
LFernandez at codesyntax.com
Fri May 6 13:36:15 CEST 2005
>
> * Image addition and management: pictures get embedded into posts.
> This feature is based on the work of Jeff Hicks, Brady Davis and friends
> at Blogplot.com
>
>Regarding this last feature, see how it works in our demo,
>http://www.datamina.net/blogak/csblog-en/1
>or in sites related to the Blogplot crew, the inventors of it,
>http://blogplot.com/40
>http://jrhicks.net/84
Regarding this feature, as it is noted by the Blogplot crew at this
message, http://blogplot.com/43 ,
users may get used to upload images of any size, as they are automatically
resized, people with no clues about storage at blogs may upload too much Mb's.
So the Blogplot people devised a system to put maximum image size at 100
Kb.I asked Brady of Blogplot for the recipe, and got this answer.
1. In "Entry.py" add these lines near the top for easy access to
change. Note I have upped the size to 100k due to user complaints.
Whats 10k going to hurt anyway? :)
Start code --->
#Statics
MAXIMAGESIZE = 100000
MAXIMAGESIZEMSG = '<h2><font color="red">Maximum Image Size Exceeded.
Please resize and compress your images to under 100 kb.</font></h2>'
End code ---->
2. Also in "Entry.py", update "manage_addImageScript()" to the following:
Start Code --->
security.declareProtected(AddCOREBlogEntries, 'manage_addImageScript')
def manage_addImageScript(self):
context = self
if context.REQUEST.has_key('pic1'):
file = context.REQUEST['pic1']
filelength = len(file.read())
if filelength > MAXIMAGESIZE:
return MAXIMAGESIZEMSG
name = context.ZopeTime().strftime('img_%b_%d_%Y_%M_%S')
file.seek(0)
context.manage_addProduct['Photo'].manage_addPhoto(name,name,file,engine='PIL',quality=90)
photo = getattr(context,name)
for property in
['placement','border','display_size','zoom','caption']:
photo.manage_addProperty(property,
context.REQUEST[property], 'string')
if context.REQUEST.has_key('deletebox'):
ids = context.REQUEST['deletebox']
context.manage_delObjects(ids)
return ''
End Code --->
That should do it. Credit goes to:
Brady Davis http://conversationswithmyself.com
Jeff Hicks http://jrhicks.net
---
Luistxo
More information about the COREblog-en
mailing list