I send digest newsletters with the subscription module, sometimes containing a small image before the teasertext (positioned with tables/row/column). This is all working well.

However in case there is no image available (because there is no teaser image uploaded to the applicable field) I get an ugly image outline in most email clients.
I would like to test if there is an image available and if not, not adding the first <td>...</td> leaving only the teaser text.

Can you explain which "subscription" code must be used in order to achieve this?

Comments

salvis’s picture

What's the code used to insert the image?

herbiek’s picture

The code used:

{{[subs:items:count]#<img src="@Mydomain@/Newsletter/fine-line.jpg" width="580" height="18"><br />

#1 of [subs:items:count] {{[subs:items:index:#0:subs:is-new]?(new):}}{{[subs:items:index:#0:subs:is-updated]?(updated):}}{{[subs:items:index:#0:subs:is-old]?(commented): <b>[subs:items:index:#0:as-node:title]</b>}}

<table border="0" width="100%" padding="5">
    <tr>
        <td valign="top"><img src="[subs:items:index:#0:as-node:field_news_image]" alt="teaser image" width="100" /></td>
        <td style="font-family: Calibri, Arial, Helvetica, sans-serif;" valign="top" align="left">[subs:items:index:#0:as-node:summary]</td>
    </tr>
 </table>
Read more: [subs:items:index:#0:as-node:url]<br />
}}
salvis’s picture

So

[subs:items:index:#0:as-node:field_news_image]

gives you path to the image, right?

What does it give you when there's no image in the node?

(Try outputting the value as text, outside the <img> tag, something like

@@@[subs:items:index:#0:as-node:field_news_image]@@@

)

herbiek’s picture

Depending on the email client used, you will see:
- Nothing visible of something missing (Outlook desktop):

<table border="0" width="100%" padding="5"><tr><td valign="top"><img src="" alt="teaser image" width="100"></td>
<td style="font-family: Calibri, Arial, Helvetica, sans-serif;" valign="top" align="left">

- only the text "teaser image" (Google webmail)
- a box with the text "teaser image" (Hotmail webmail)

<table width="100%" border="0">
    <tbody>
        <tr>
            <td valign="top">
                <img width="100" alt="teaser image" src="https://"></img>
            </td>
            <td valign="top" align="left" style="font-family:Calibri, Arial, Helvetica, sans-serif;"></td>
        </tr>
    </tbody>

</table>

Can you explain what you mean with "(Try outputting the value as text, outside the Only local images are allowed. tag, something like .."?

herbiek’s picture

Maybe I understood what you meant, I put the code as suggested in my template between

and

(between the expected image and teaser text)
This was what the output:

Outlook: @@@@@@ and then the teaser text
Gmail: text "teaser image" , @@@@@@ and then the teaser text.

salvis’s picture

Status: Active » Fixed

Ok, seeing the six @s means that you get an empty string if you have no image.

You can use the usual conditional expression that is documented inside the collapsed "Dynamic text information" fieldset at the bottom of the page, i.e.

{{[subs:items:index:#0:as-node:field_news_image]==?probably_nothing:<td><img ...></td>}}

(Note the emptyness between == and ?: if the token returns nothing you return probably_nothing and otherwise you return your <td> element.)

BTW, I'd recommend using the current -dev version...

herbiek’s picture

I've managed to test for an empty image successfully. Thanks for your help!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.