{"id":75,"date":"2011-11-17T20:42:51","date_gmt":"2011-11-18T04:42:51","guid":{"rendered":"http:\/\/shanelabs.com\/blog\/?p=75"},"modified":"2011-12-15T21:40:16","modified_gmt":"2011-12-16T05:40:16","slug":"preventing-do-you-want-to-open-or-save-this-file-from-tracking-pixel","status":"publish","type":"post","link":"https:\/\/shanelabs.com\/blog\/2011\/11\/17\/preventing-do-you-want-to-open-or-save-this-file-from-tracking-pixel\/","title":{"rendered":"Preventing &#8220;Do you want to open or save this file?&#8221; from tracking pixel"},"content":{"rendered":"<p>In developing one of my <a title=\"task management\" href=\"http:\/\/www.taskshot.com\/\">task management<\/a> projects I was playing around with creating a tracking pixel that could be used to measure performance. When this pixel was placed on the page, I noticed in Safari and IE the browser would ask me if I&#8217;d like to open or save the file.<\/p>\n<p>Safari said:<\/p>\n<blockquote><p>Do you want to open or save this file?<\/p>\n<p>Name: pixel.php<\/p>\n<p>Type: PHP File<\/p><\/blockquote>\n<p>Internet Explorer asked:<\/p>\n<blockquote><p>Do you want to open or save pixel.php from <a title=\"task shot\" href=\"http:\/\/www.taskshot.com\">taskshot.com<\/a><\/p><\/blockquote>\n<p>Both had the buttons to Open \/ Save \/ Cancel<\/p>\n<p>&nbsp;<\/p>\n<p>As you can tell, this is not what I wanted to happen, in fact, it would probably scare people away. So I looked to fix it. Here&#8217;s the code I was using:<\/p>\n<pre>\/\/spit out pixel just in case browsers want it\r\n$im=imagecreate(1,1);\r\n$white=imagecolorallocate($im,255,255,255);\r\nimagesetpixel($im,1,1,$white);\r\nheader(\"Content-type: image\/jpg\");\r\nimagejpeg($im);\r\nimagedestroy($im);<\/pre>\n<p>I thought something had to be wrong with the header, and after trying another file type with success, I tried changing the content-type from jpg to jpeg.<\/p>\n<pre>header(\"Content-type: image\/jpeg\");<\/pre>\n<p>Surprisingly enough, that was all it took to fix it. I don&#8217;t remember where I got this sample code from, but it was wrong. Content type for JPEGs should be image\/jpeg, not image\/jpg.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In developing one of my task management projects I was playing around with creating a tracking pixel that could be used to measure performance. When this pixel was placed on the page, I noticed in Safari and IE the browser would ask me if I&#8217;d like to open or save the file. Safari said: Do [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-75","post","type-post","status-publish","format-standard","hentry","category-software","category-web"],"_links":{"self":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/comments?post=75"}],"version-history":[{"count":6,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts\/75\/revisions"}],"predecessor-version":[{"id":124,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/posts\/75\/revisions\/124"}],"wp:attachment":[{"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/media?parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/categories?post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shanelabs.com\/blog\/wp-json\/wp\/v2\/tags?post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}