Possible to display JPG attachment in email

classic Classic list List threaded Threaded
26 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Possible to display JPG attachment in email

Coleen_Astalos
With the changes you made to "message_as_html" for me, is it possible if the attached file is a JPG file to actually display the picture (or a thumbnail view of it) by inserting the link in an html img tag rather than just having a link to the JPG file?
Thanks,
Coleen
Reply | Threaded
Open this post in threaded view
|

Re: Possible to display JPG attachment in email

Coleen_Astalos
I was wondering what you thought about this...  

It seems like it would be fairly easy to replace the existing attachments icon (the paperclip one that you just fixed for me) with the actual JPG image (since you have the link to the actual JPG).  But rather than it being tiny like the paperclip one - specify bigger thumbnail size (like 200 pixels in height) and then follow it with the link like you have now - so people could click on the link to see the full size image.

So something like... (just replacing the image for the icon attachment with the JPG image itself & setting the height larger):


So it looks like this at the top of the email:


Thoughts?
Coleen

Reply | Threaded
Open this post in threaded view
|

Re: Possible to display JPG attachment in email

Pedro <Nabble>
Have you tried to do something?
My test forum.
Reply | Threaded
Open this post in threaded view
|

Re: Possible to display JPG attachment in email

Coleen_Astalos
No, I haven't tried anything as I don't know where the icon is put in (and I don't think it's an macro I have access to.  But if I had access, I'd be happy to try!)
Coleen
Reply | Threaded
Open this post in threaded view
|

Re: Possible to display JPG attachment in email

Pedro <Nabble>
Do you send other kind of files besides images?
My test forum.
Reply | Threaded
Open this post in threaded view
|

Re: Possible to display JPG attachment in email

Pedro <Nabble>
In reply to this post by Coleen_Astalos
Please, try this code:
<override_macro name="message_as_html" requires="message">
    <n.if.either condition1="[n.is_deleted/]" condition2="[n.is_deactivated/]">
        <then>
            <b><t>CONTENTS DELETED</t></b>
            <div class="weak-color"><t>The author has deleted this message.</t></div>
        </then>
        <else>
            <n.set_var. name="output">
                <n.as_html_list.process_message_html />
            </n.set_var.>
            
            <n.if.is_imported_mail>
                <then>
                    <n.set_var. name="output">
                        <n.remove_unsubscription_link.var name="output" />
                    </n.set_var.>                
                    
                    <n.comment>
                        PART 1: Copy the attachment links to a variable
                    </n.comment>
                    <n.set_var. name="attachments">                
                        <n.regex. text="[n.var name='output'/]" pattern="[n.attachments_regex/]">
                            <n.if.find>
                                <then.found/>
                            </n.if.find>
                        </n.regex.>                
                    </n.set_var.>
                    

                    <n.set_var. name="thumb_url">   
                        <n.regex. text="[n.var name='attachments'/]" pattern="[n.href_regex/]">
                            <n.if.find>
                                <then>    
                                    <n.regex_replace_all text = "[n.found/]" pattern="href=" replacement = ''/>    
                                </then>
                            </n.if.find>
                        </n.regex.>  
                    </n.set_var.>    
                    
                    
                   
                    <n.regex. text="[n.var name='thumb_url'/]" pattern="\w+\.(jpg|gif|png)">
                        <n.if.find>
                            <then>    
                                <n.set_var. name="thumb_url">                                   
                                    height = '100px' width='100px' src=
                                    <n.regex_replace_all text = "[n.var name='thumb_url'/]" pattern="href=" replacement = ''/>
                                    \>           
                                </n.set_var.>   
                                <n.set_var. name="attachments">                
                                    <n.regex_replace_all text = "[n.var name='attachments'/]" pattern="[n.img_regex/]" replacement = "[n.var name='thumb_url'/]"/>  
                                </n.set_var.>                               
                            </then>
                        </n.if.find>
                    </n.regex.>  
                      
   
                    


                    
                    <n.comment>
                        PART 2: Rebuild the "output" variable by placing the attachments at the top.
                        At the end, we remove the old attachments so that we don't show duplicate links.
                    </n.comment>
                    <n.set_var. name="output">
                        <n.var name='attachments' />
                        <br/>
                        <n.regex_replace_all text = "[n.var name='output'/]" pattern="[n.attachments_regex/]" replacement ='' />
                    </n.set_var.>    
                                       
                    
                </then>                    
            </n.if.is_imported_mail>
            <n.var name="output" />
        </else>
    </n.if.either>
</override_macro>

<macro name="attachments_regex">
    <![CDATA[<!--start-attachments-->.*<!--end-attachments-->]]>
</macro>
<macro name="img_regex">
    <![CDATA[src=.*?\>]]>
</macro>
<macro name="href_regex">
    <![CDATA[href="([^"]*)"]]>
</macro>
My test forum.
Reply | Threaded
Open this post in threaded view
|

RE: Possible to display JPG attachment in email

Coleen_Astalos
This post was updated on .
I'm out of town for the week.  Will try this when I get home this weekend.
Thanks!

Coleen

 

Coleen Astalos, Stampin' Up! Demonstrator
Alamosa, CO,  <mailto:coleen@sudsol.com> coleen@sudsol.com
See my website at  <http://alamosa.stampinup.net/>
http://alamosa.stampinup.net
Are you a demonstrator?  <http://www.cartville.com/app/?Clk=2848375> Join me
on SUDSOL - Your 24/7 Upline!

 
Reply | Threaded
Open this post in threaded view
|

Re: Possible to display JPG attachment in email

Coleen_Astalos
In reply to this post by Pedro <Nabble>
I like how it also shows the image online in the forum as well.  Displayed in Outlook, it works great as long as only one picture is attached to the email.  If there is more than one, then none of them have the thumbnail icon.

However even with one image attached, it doesn't seem to work properly with Gmail.   If I compose an email in Gmail and attach a .jpg file, it uses the standard attachment icon instead.  If I compose an email in Outlook and attach a .jpg file, it uses the picture as the icon as expected, but when that email is viewed in Gmail doesn't display. The box outlining the image initially comes up as the email is loading in Gmail, then the box disappears (the picture is never displayed).   The thumbnail picture is part of the email, because when that same email gets delivered from Gmail to my Outlook, the picture is there & displays fine.  Other images people include in the body of the email do display fine in my Gmail.  So I don't know why these wouldn't.

Coleen
Reply | Threaded
Open this post in threaded view
|

Re: Possible to display JPG attachment in email

Pedro <Nabble>
One more test. Please, subscribe here http://pedro-3.1104361.n5.nabble.com/ and post an image with your gmail.
My test forum.
Reply | Threaded
Open this post in threaded view
|

Re: Possible to display JPG attachment in email

Coleen_Astalos
Sent.
Reply | Threaded
Open this post in threaded view
|

Re: Possible to display JPG attachment in email

Pedro <Nabble>
Please, test once again in my forum. It was case sensitive.
Now, I replaced the old regex with this "\w+\.(jpg|gif|png|JPG|GIF|PNG)", please, try again.
My test forum.
Reply | Threaded
Open this post in threaded view
|

Re: Possible to display JPG attachment in email

Pedro <Nabble>
Your test in my forum was good. I've made the change on your forum, please, try again there.
My test forum.
Reply | Threaded
Open this post in threaded view
|

RE: Possible to display JPG attachment in email

Coleen_Astalos

The problem is if I'm not logged into my site, then the image doesn't display - because of the custom domain name / redirect to my forum.sudsol.org site (which is password protected).  So, if I'm not logged in to my site, it looks like this:

Yet if I click on the "Download Attachment" link, it displays the image (without requiring me to login to my site first).  So I don't know why the thumbnail image wouldn't work the same way…   Thoughts?

 

-Coleen

 

Coleen Astalos, Stampin' Up! Demonstrator
Alamosa, CO, [hidden email]
See my website at http://alamosa.stampinup.net
Are you a demonstrator? Join me on SUDSOL - Your 24/7 Upline!

 

From: Pedro <Nabble> [via Nabble Support] [mailto:[hidden email]]
Sent: Tuesday, February 04, 2014 9:16 PM
To: Coleen_Astalos
Subject: Re: Possible to display JPG attachment in email

 

Your test in my forum was good. I've made the change on your forum, please, try again there.

My test forum.

 


If you reply to this email, your message will be added to the discussion below:

http://support.nabble.com/Possible-to-display-JPG-attachment-in-email-tp7589178p7589339.html

To unsubscribe from Possible to display JPG attachment in email, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

RE: Possible to display JPG attachment in email

Coleen_Astalos
Just did another test - it doesn't seem to matter if I'm logged into my SUDSOL site or not, the thumbnails are still showing as a broken link (as shown in the previous post) - for both images attached and sent via Gmail or via Outlook.

-Coleen
Reply | Threaded
Open this post in threaded view
|

RE: Possible to display JPG attachment in email

Coleen_Astalos
I've done some more testing and I *think* I've figured out when the emails show the thumbnails and when they don't.  

The thumbnails show on categories where the View permissions are set to "Anyone".  They don't seem to show the thumbnails where the View permission are set to something other than "Anyone" - even if the person getting the email is an administrator or authorized user of that section and able to view the items from that section.

I was not seeing the thumbnails for any of the posts to the Newsletter Coop section that I am using for testing.  But I was getting the thumbnails in emails sent by other members to our Creative Idea Share section.  The Newsletter Coop section permissions for viewing are set to only"Administrators" or those in the "Newsletter Coop" group.  The Creative Idea Share section permissions for viewing are set to "Anyone".

I changed the View permissions of the Newsletter Coop section to "Anyone" and then sent an email with an attachment.  The thumbnail showed up fine.  I then changed the View permissions back to only admin/Newsletter Coop members and sent another email with an attachment.  Again I could not see the thumbnail (even though I'm both an administrator as well as a member of the Newsletter Coop group).  Instead I saw the broken link icon.  If I click on the "Download Attachment" link, I'm able to see the image - regardless of whether I'm a member of the group or not.

Ideas?
Coleen
Reply | Threaded
Open this post in threaded view
|

RE: Possible to display JPG attachment in email

Pedro <Nabble>
I believe that the broken links come when your forum is private and the user is not logged in. We can't change that, it is a security feature related to email softwares.
What do think of alert in the email when the post contains an image? Actually, the broken link has been doing it already.
My test forum.
Reply | Threaded
Open this post in threaded view
|

RE: Possible to display JPG attachment in email

Coleen_Astalos
I thought that initially as well (that it was because it was behind a password protected area).  But my testing showed that the images show fine for the sections that are visible to "Anyone", it's just the sections that have restricted visibility (not visible to "Anyone") - and it's not related to the password protection on my site, but actually related to being logged into Nabble or not.  

Currently it's not a problem for me because I'm only using the section that isn't visible to all for testing.   When I start using the section that is set up for only some to view, I'll just let them know that the thumbnails may or may not show for them - they can always click the attachment to see the image.

Thanks,
Coleen
Reply | Threaded
Open this post in threaded view
|

Re: Possible to display JPG attachment in email

Coleen_Astalos
In reply to this post by Pedro <Nabble>
You provided this customization for us to display a picture of an image file instead of the standard paperclip icon:
Pedro <Nabble> wrote
Please, try this code:
<override_macro name="message_as_html" requires="message">
    <n.if.either condition1="[n.is_deleted/]" condition2="[n.is_deactivated/]">
        <then>
            <b><t>CONTENTS DELETED</t></b>
            <div class="weak-color"><t>The author has deleted this message.</t></div>
        </then>
        <else>
            <n.set_var. name="output">
                <n.as_html_list.process_message_html />
            </n.set_var.>
            
            <n.if.is_imported_mail>
                <then>
                    <n.set_var. name="output">
                        <n.remove_unsubscription_link.var name="output" />
                    </n.set_var.>                
                    
                    <n.comment>
                        PART 1: Copy the attachment links to a variable
                    </n.comment>
                    <n.set_var. name="attachments">                
                        <n.regex. text="[n.var name='output'/]" pattern="[n.attachments_regex/]">
                            <n.if.find>
                                <then.found/>
                            </n.if.find>
                        </n.regex.>                
                    </n.set_var.>
                    

                    <n.set_var. name="thumb_url">   
                        <n.regex. text="[n.var name='attachments'/]" pattern="[n.href_regex/]">
                            <n.if.find>
                                <then>    
                                    <n.regex_replace_all text = "[n.found/]" pattern="href=" replacement = ''/>    
                                </then>
                            </n.if.find>
                        </n.regex.>  
                    </n.set_var.>    
                    
                    
                   
                    <n.regex. text="[n.var name='thumb_url'/]" pattern="\w+\.(jpg|gif|png)">
                        <n.if.find>
                            <then>    
                                <n.set_var. name="thumb_url">                                   
                                    height = '100px' width='100px' src=
                                    <n.regex_replace_all text = "[n.var name='thumb_url'/]" pattern="href=" replacement = ''/>
                                    \>           
                                </n.set_var.>   
                                <n.set_var. name="attachments">                
                                    <n.regex_replace_all text = "[n.var name='attachments'/]" pattern="[n.img_regex/]" replacement = "[n.var name='thumb_url'/]"/>  
                                </n.set_var.>                               
                            </then>
                        </n.if.find>
                    </n.regex.>  
                      
   
                    


                    
                    <n.comment>
                        PART 2: Rebuild the "output" variable by placing the attachments at the top.
                        At the end, we remove the old attachments so that we don't show duplicate links.
                    </n.comment>
                    <n.set_var. name="output">
                        <n.var name='attachments' />
                        <br/>
                        <n.regex_replace_all text = "[n.var name='output'/]" pattern="[n.attachments_regex/]" replacement ='' />
                    </n.set_var.>    
                                       
                    
                </then>                    
            </n.if.is_imported_mail>
            <n.var name="output" />
        </else>
    </n.if.either>
</override_macro>

<macro name="attachments_regex">
    <![CDATA[<!--start-attachments-->.*<!--end-attachments-->]]>
</macro>
<macro name="img_regex">
    <![CDATA[src=.*?\>]]>
</macro>
<macro name="href_regex">
    <![CDATA[href="([^"]*)"]]>
</macro>
This works great 95% of the time when my members only have one image attached to an email.  However, when they have more than one image the first image is displayed for all the icons.

This is confusing to many members as they think each attachment is the same.   So I'm looking for alternate solutions for the case where there are multiple images attached to an email.

The ideal solution would be that the corresponding image is displayed for each attachment.  Is that possible?

If that is not possible I have some alternate ideas we could explore.

Let me know,
Thanks,
Coleen

Reply | Threaded
Open this post in threaded view
|

Re: Possible to display JPG attachment in email

Pedro <Nabble>
Please, explain to me your ideas.
My test forum.
Reply | Threaded
Open this post in threaded view
|

Re: Possible to display JPG attachment in email

Coleen_Astalos
The ideal solution would be to display the thumbnail icon with each associated image.  One thought I had for doing that was to search for the first attachment, replace the thumb_url for it and change the wording "Download Attachment" to "Download Picture"  (so then you could repeat the search for the second Attachment and not have it pick up the first one again), replace the thumb_url & wording for it, then repeat until there are no more attachments.

The next best solution would be to do like it is now, find the first attachment, but then only replace the first thumb_url.  So the remaining pictures would just show the default paperclip icon.

The last solution would be if there are more than one attachment to not replace any of the icons (I do NOT think my members want this solution - I'm currently gathering their input and so far they'd rather stick with the way it is now than have no pictures displayed).

Let me know what you think.
Coleen
12