Add email placeholder for picture
Request to add a placeholder to display the personal data picture in email.
I updated the code using cid, but for the preview it doesn't work as attachments can't be done. Do you have a solution for it ?
I updated the code using cid, but for the preview it doesn't work as attachments can't be done. Do you have a solution for it ?
Damn, forgot about the preview... One solution could be to use a base64 data url for this placeholder while rendering the preview. Or use your original solution for the preview and the cid only when generating the actual mail.
To render differently the picture in preview, I need to know the context "preview". I see 3 ways to do it:
- check directly flask.request in PicturePlaceHolder.render();
- add context preview when calling replace_placeholder of email_body, then add '**kwargs' to all placeholders 'render':
email_body = replace_placeholders('registration-email', request.form['body'], regform=self.regform,
registration=registration, preview=True)
def render(cls, regform, registration, **kwargs):
if kwargs['preview']...
- get new placeholders for 'registration-email-preview' with a PicturePreviewPlaceHolder:
email_body = replace_placeholders('registration-email-preview', request.form['body'], regform=self.regform,
registration=registration)
@signals.core.get_placeholders.connect_via('registration-email-preview')
def _get_registration_placeholders_preview(sender, regform, registration, **kwargs):
yield PicturePreviewPlaceHolder
yield ...
What would be your suggestion ?
i had option 2 in mind, but i somehow thought we already accept kwargs and thus would not need to modify every placeholder... maybe checking if request.endpoint == 'event_registration.email_registrants_preview' (so kind of option 1) is not too ugly
One last point: in picture rendering, you use a fixed max-height/width = 250px, we would like to have a different value. Can I use a parameter in config for that value ? (same for REGISTRATION_PICTURE_THUMBNAIL_SIZE which is in a constants.py file)
constant in python sure, but I don't think having an indico.conf setting for this would really make sense - it's SO specific and probably you guys are the only ones who would change this...