PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Adding custom id="" to Post Content

  1. freiden
    Member

    I'm inserting an image upload into the body field of a form via post content template, which outputs this into the template:
    {Image::7:thumbnail:center}

    However, I need to add a custom id="" tag into the html for that image that is posted.

    Right now, this is what is generated into the post content:
    <img class="size-thumbnail aligncenter wp-image-285" title="jcrew_grey_tweed_sportcoat" src="http://www.styleroast.com/wp-content/uploads/2010/11/jcrew_grey_tweed_sportcoat3.jpg" alt="jcrew_grey_tweed_sportcoat" width="500" height="500" />

    How can I make it this:

    <img id="img-POSTIDHERE" class="size-thumbnail aligncenter wp-image-285" title="jcrew_grey_tweed_sportcoat" src="http://www.styleroast.com/wp-content/uploads/2010/11/jcrew_grey_tweed_sportcoat3.jpg" alt="jcrew_grey_tweed_sportcoat" width="500" height="500" />

    Thanks!

    Posted 14 years ago on Tuesday November 16, 2010 | Permalink
  2. You can't add code to the output. What you would have to do is build the entire image tag yourself. You can then modify the form field variable for the post image using an undocumented feature to only output the full path to the image.

    You would do so by adding :url to the post image variable.

    Example:

    {Image:7:thumbnail:url}

    This will only output the full path to the image like this:

    http://www.styleroast.com/wp-content/uploads/2010/11/jcrew_grey_tweed_sportcoat3.jpg

    So you would then build the full image tag yourself like so:

    <img id="img-POSTIDHERE" class="size-thumbnail aligncenter wp-image-285" title="jcrew_grey_tweed_sportcoat" src="{Image:7:thumbnail:url}" alt="jcrew_grey_tweed_sportcoat" width="500" height="500" />

    Posted 14 years ago on Tuesday November 16, 2010 | Permalink