1

Basic blog setup using Wygwam for the primary field in the entry. Inside the file management, I have Image Manipulations set to manipulate any images uploaded and used formatted for social media. For instance, since the twitter images for twitter card data must be at least 280x150, I just create better optimized images for them and they are dumped in a sub-folder of images named "_Twitter_Card_Image".

Is there any way to find if an entry has an image in the Wygwam field and add a META tag for each image used?

Something like:

{wygwam-field}
    <meta name="twitter:image:src" content="{twitter-image-location}">
{/wygwam-field}

I've never done this before. It may be something pretty simple that I'm over thinking.

* EDIT *

Sorry, I should have been more clear. (Trying to post and answer questions when people walk up.)

I know of the images only tag. I wasn't exactly clear about the needs. I need the alternate image source for the Image Manipulation option spoken of above.

{my_wygwam_field images_only="yes"}
    <meta name="twitter:image:src" content="{twitter-image-location}">
{/my_wygwam_field}

* UPDATE *

<!-- Twitter summary card with large image must be at least 280x150px -->
{app_primary_copy images_only="yes"}
    <meta name="twitter:image:src" content="{exp:low_replace find='/appraisers/' replace='/appraisers/_Twitter_Card_Image'}{src}{/exp:low_replace}">
{/app_primary_copy}

<!-- Open Graph data -->
<meta property="og:title" content="{title}" />
<meta property="og:type" content="article" />
<meta property="og:url" content="{current_url}" />
{app_primary_copy images_only="yes"}
    <meta property="og:image" content="{src}" />
{/app_primary_copy}
<meta property="og:description" content="{exp:eehive_hacksaw chars = '150' append = '...'}{app_primary_copy}{/exp:eehive_hacksaw}" />

So the hacksaw info comes in just fine, but the rest of the info that's wrapped in EE Tags is completely blank. Basically, the wygwam tags aren't producing any results. No HTML or anything. It's like there is nothing there at all.

0

1 Answer 1

0

Wygwam has an Images-only Mode you can use for this.

{your_wygwam_field images_only="yes"}
     <meta name="twitter:image:src" content="{src}">
{/your_wygwam_field}

http://docs.pixelandtonic.com/wygwam/templating/field.html#images-only-mode

UPDATE to address your image path question

Since EE is systematic about storing manipulated versions of an image in a subfolder named after the manipulation, and otherwise uses the same filename, you could just use Low Replace. The exact parameters you use will depend on your setup, but for the sake of example if your image upload directory is "assets/twitter" and your manipulation is called "card" you can use

{your_wygwam_field images_only="yes"}
     <meta name="twitter:image:src" content="{exp:low_replace find="/assets/twitter" replace="/assets/twitter/_card"}{src}{exp:low_replace}">
{/your_wygwam_field}
8
  • Alex, thanks. I know of that tag, but don't know how to get the alternate path. Do you know if that is possible?
    – W3bGuy
    Nov 11, 2013 at 19:27
  • OK, I see you updated your question and this is more about a cached, manipulated image path. What method are you using for that (CE Image? Something else?)
    – Alex Kendrick
    Nov 11, 2013 at 19:30
  • In the "Edit File Upload Preferences" I have the "Image Manipulations" set to create alternate versions of the images as they are uploaded in the Wygwam field. These are placed in a folder named after the name of the manipulation. So in this particular case, the image is uploaded to the folder assigned to the file management field used in the wygwam field and the twitter optimized images are saved in a sub-folder named "_Image Manipulations name" with the same file name. This is the image I want to get.
    – W3bGuy
    Nov 11, 2013 at 19:35
  • Since the path to EE's manipulated versions is predictable and systematic you could just wrap Low Replace around the {src} provided by Wygwam and adjust the path accordingly.
    – Alex Kendrick
    Nov 11, 2013 at 19:46
  • 1
    False alarm. It was a caching issue. It worked like a charm. Thanks again.
    – W3bGuy
    Nov 11, 2013 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.