I’ll directly jump into this topic. The solution above doesn’t fix Twitter cards for me, as I’m not using cover images. Is there also a way to use just the first image embedded in a article?
Ahhhhh… with that snippet its working. You are wonderful
Maybe you can also help with the excerpt - I just need a little tweak: Is there a way to check IF there is text inside the post, and if not take the post title as description (instead of the text excerpt)? I often publish just a picture with a only a subject line.
Thanks for the snippet, works for standard articles (with text). Unfortunately it doesn’t work for posts with not text and with a embedded image. IMHO thats because the image is part of the text, so that the text isn’t empty. Could that be the cause?
Thanks Texnixe, that solved the problem. You are awesome
Just in case, somebody else wants to use this snippet, there need to be done a small correction (you missed the } before the else).
I would just like to point out that theres a good plugin for this that is very powerful. Meta Tags Plugin
If you still want to do it by hand then maybe using the code i used prior to finding the plugin might help… you can add your image stuff to it. Does require a couple of extra blueprint entries to capture SEO title & description and keywords:
Does anyone have a suggestion for adding a condition for a Twitter Image?
For instance if an image is not found for a page use a default image from NAMED URL.
I can’t seem to get this to work consistently.
Something like this <meta name="twitter:image" content="<?php if(! $page->image()) { echo $image->url(); } else { echo 'DEFAULT IMAGE URL' ?>" />
Sorry I thought I fixed my syntax on the original post, but it looks like I deleted my corrected post by accident. You are right I got the not operator all wrong.