{"id":31418,"date":"2018-04-21T15:47:46","date_gmt":"2018-04-21T15:47:46","guid":{"rendered":"https:\/\/ampscript.guide\/contentimagebyid\/"},"modified":"2021-04-06T01:18:24","modified_gmt":"2021-04-06T01:18:24","slug":"contentimagebyid","status":"publish","type":"post","link":"https:\/\/ampscript.guide\/contentimagebyid\/","title":{"rendered":"ContentImageByID"},"content":{"rendered":"<h2>ContentImageByID<\/h2>\n<p>This function returns an HTML <code>img<\/code> tag with the specified Content Builder image.  It also sets the <code>title<\/code>, <code>alt<\/code>, <code>border<\/code> and <code>thid<\/code> attributes on the <code>img<\/code> tag.  The <code>title<\/code> and <code>alt<\/code> values are set to the name of the image as defined in Content Builder.  The <code>border<\/code> is set to <code>0<\/code> in all circumstances.  The <code>thid<\/code> is a proprietary Marketing Cloud attribute that contains the ID of the specified image in Content Builder.<\/p>\n<h3>Arguments<\/h3>\n<p><code>ContentImageByID(1,2)<\/code><\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center\">Ordinal<\/th>\n<th style=\"text-align: left\">Type<\/th>\n<th style=\"text-align: left\">Required<\/th>\n<th style=\"text-align: left\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center\">1<\/td>\n<td style=\"text-align: left\">String<\/td>\n<td style=\"text-align: left\">True<\/td>\n<td style=\"text-align: left\">ID value of the image to return<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">2<\/td>\n<td style=\"text-align: left\">String<\/td>\n<td style=\"text-align: left\">False<\/td>\n<td style=\"text-align: left\">ID value of the image to return if the image for the specified ID is not found<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote>\n<p>NOTE: The ID for the image can be found in the Properties menu, accessible from the drop-down menu on the right-hand side of the Content Builder asset listing page.<\/p>\n<p>NOTE: This function will only return Content Builder assets that are images.  It will <em>not<\/em> return an Image Block from Content Builder.<\/p>\n<\/blockquote>\n<h3>Example 1<\/h3>\n<pre><code>%%[\n\nvar @imageID, @imageTag\nset @imageID = \"5940\" \/* limedash-logo-green *\/\n\nset @imageTag = ContentImageByID(@imageID)\n\n]%%\n&lt;a href=\"https:\/\/limedash.com\"&gt;\n%%=v(@imageTag)=%%\n&lt;\/a&gt;<\/code><\/pre>\n<h4>Output<\/h4>\n<pre><code>&lt;a href=\"https:\/\/limedash.com\"&gt;\n&lt;img title=\"limedash-logo-green\" alt=\"limedash-logo-green\" src=\"http:\/\/image.S7.exacttarget.com\/lib\/fe9213727567077b7d\/m\/1\/087ae025-7205-4121-8d5c-366f4a3dc117.png\" border=\"0\" thid=\"5940\"&gt;\n&lt;\/a&gt;<\/code><\/pre>\n<h3>Example 2<\/h3>\n<p>This example illustrates the output when the specified ID does not exist and the fallback image is returned:<\/p>\n<pre><code>%%[\n\nvar @imageID, @imageIDFallBack, @imageTag\nset @imageID = \"5999\" \/* does not exist *\/\nset @imageIDFallBack = \"5941\" \/* limedash-logo-gray *\/\n\nset @imageTag = ContentImageByID(@imageID, @imageIDFallBack)\n\n]%%\n&lt;a href=\"https:\/\/limedash.com\"&gt;\n%%=v(@imageTag)=%%\n&lt;\/a&gt;<\/code><\/pre>\n<h4>Output<\/h4>\n<pre><code>&lt;a href=\"https:\/\/limedash.com\"&gt;\n&lt;img title=\"limedash-logo-gray\" alt=\"limedash-logo-gray\" src=\"http:\/\/image.S7.exacttarget.com\/lib\/fe9213727567077b7d\/m\/1\/8aabd3b9-cf2a-4d41-a56b-bec76e2efd54.png\" border=0 thid=\"5941\"&gt;\n&lt;\/a&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>ContentImageByID This function returns an HTML img tag with the specified Content Builder image. It also sets the title, alt, border and thid attributes on the img tag. The title and alt values are set to the name of the image as defined in Content Builder. The border is set to 0 in all circumstances. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v14.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The AMPscript Guide - ContentImageByID<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ampscript.guide\/contentimagebyid\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The AMPscript Guide - ContentImageByID\" \/>\n<meta property=\"og:description\" content=\"ContentImageByID This function returns an HTML img tag with the specified Content Builder image. It also sets the title, alt, border and thid attributes on the img tag. The title and alt values are set to the name of the image as defined in Content Builder. The border is set to 0 in all circumstances. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ampscript.guide\/contentimagebyid\/\" \/>\n<meta property=\"og:site_name\" content=\"The AMPscript Guide\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-21T15:47:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-06T01:18:24+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ampscript.guide\/#website\",\"url\":\"https:\/\/ampscript.guide\/\",\"name\":\"The AMPscript Guide\",\"description\":\"The Definitive Scripting Manual for Salesforce Marketing Cloud\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/ampscript.guide\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/contentimagebyid\/#webpage\",\"url\":\"https:\/\/ampscript.guide\/contentimagebyid\/\",\"name\":\"The AMPscript Guide - ContentImageByID\",\"isPartOf\":{\"@id\":\"https:\/\/ampscript.guide\/#website\"},\"datePublished\":\"2018-04-21T15:47:46+00:00\",\"dateModified\":\"2021-04-06T01:18:24+00:00\",\"author\":{\"@id\":\"https:\/\/ampscript.guide\/#\/schema\/person\/5335042f77731e84f9808aecef25daec\"},\"breadcrumb\":{\"@id\":\"https:\/\/ampscript.guide\/contentimagebyid\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ampscript.guide\/contentimagebyid\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ampscript.guide\/contentimagebyid\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/\",\"url\":\"https:\/\/ampscript.guide\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/contentimagebyid\/\",\"url\":\"https:\/\/ampscript.guide\/contentimagebyid\/\",\"name\":\"ContentImageByID\"}}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/ampscript.guide\/#\/schema\/person\/5335042f77731e84f9808aecef25daec\",\"name\":\"dev\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","_links":{"self":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31418"}],"collection":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/comments?post=31418"}],"version-history":[{"count":0,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31418\/revisions"}],"wp:attachment":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/media?parent=31418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/categories?post=31418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/tags?post=31418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}