{"id":10920,"date":"2014-12-06T05:06:04","date_gmt":"2014-12-05T18:06:04","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=10920"},"modified":"2014-12-06T05:06:04","modified_gmt":"2014-12-05T18:06:04","slug":"wordpress-blog-custom-header-image-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wordpress-blog-custom-header-image-primer-tutorial\/","title":{"rendered":"WordPress Blog Custom Header Image Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/SVG_Mask_RoundedBorder.jpg\"><img decoding=\"async\" id=\"fghjspt\" style=\"float:left;border: 15px solid pink;\" alt=\"Wordpress Blog Custom Header Image Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/SVG_Mask_RoundedBorder.jpg\" title=\"Wordpress Blog Custom Header Image Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Wordpress Blog Custom Header Image Primer Tutorial<\/p><\/div>\n<p>The HTML5 specification allows for the display of 2D-graphics via <a target=_blank href='http:\/\/www.tutorialspoint.com\/html5\/html5_svg.htm' title='SVG information'>SVG HTML tags<\/a> which use graphical applications in XML and the XML is then rendered by an SVG viewer.   SVG stands for Scalable Vector Graphics.<\/p>\n<p>Those SVG shapes can be used as a mask for an HTML image <i>img<\/i> element as we do, for our WordPress blog title image, at least for the Firefox browser &#8230; you guessed it &#8230; a cross-browser (browser age) issue.  For the non-Firefox browser we try to hook into the bold parts of the changes to the WordPress <i>header.php<\/i> PHP code snippet 2 of 3 below:<\/p>\n<p><code>echo \"n\" . '<b>&lt;style&gt;#mytopimage {<\/b> mask: url(#m1); <b>-webkit-border-bottom-left-radius: 200px; -webkit-border-bottom-right-radius: 200px; background-color: #fffff0; }&lt;\/style&gt;<\/b><\/code><\/p>\n<p>&#8230; the non-bold bit is a Firefox SVG mask parameter as with the right hand part of the tutorial <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/SVG_Mask_RoundedBorder.jpg\" title=\"Click picture\">image<\/a> here today.<\/p>\n<p>Up the top of <i>header.php<\/i> we apply a SVG mask or rounded border to the new photos we have recently introduced into the <i>&#8220;mix&#8221;<\/i> of random photos presented &#8230; and why do we do this? &#8230; well, these photos don&#8217;t always suit the dimensional perspective of this area, and with some photos it is more important to keep their dimensional perspective than try to fit a round peg into a square hole &#8230; so if this is the case what is a way to merge it in a bit more naturally? &#8230; find, myself, some masking or border interest fits this <i>&#8220;bill&#8221;<\/i>, but this is definitely a subjective matter.  Here is that 1 of 3 code (where $myr is stored up to be used as an index to a random suffix part to a header image name of interest in the 3 of 3 bit &#8230; if this corresponds to one of the aspect ratios not suiting the <i>&#8220;presentation area&#8221;<\/i> we prepare for SVG functionality requirement possibilities (with how we define the HTML environment)) &#8230;<\/p>\n<p><code><br \/>\n$myr = rand(24, 43);<br \/>\nif ($myr <= 41) {\nif (($myr &gt;= 36 &#038;&#038; $myr &lt; 40) || ($myr &gt;= 32 &#038;&#038; $myr &lt; 33) || ($myr &gt;= 29 &#038;&#038; $myr &lt; 30) || ($myr &gt;= 40 &#038;&#038; $myr &lt; 42)) {\n  echo \"&lt;!DOCTYPE html&gt;n&lt;html \";\n  language_attributes();\n  echo ' xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\" ' . \"n\" . ' xmlns:svg=\"http:\/\/www.w3.org\/2000\/svg\"&gt;' . \"n\";\n} else {\n  echo \"&lt;!DOCTYPE html&gt;n&lt;html \";\n  language_attributes();\n  echo \"&gt;n\";\n}\n} else {\n  echo \"&lt;!DOCTYPE html&gt;n&lt;html \";\n  language_attributes();\n  echo \"&gt;n\";\n}\n<\/code><\/p>\n<p>... and so we come to code snippet 3 of 3 in <i>header.php<\/i>:<\/p>\n<p><code><br \/>\n<b>&lt;?php<\/b><br \/>\n     \/\/$myr = rand(24, 43);<br \/>\n     if ($myr &lt;= 41) {<br \/>\n        <b>if (1 == 6)<\/b> echo \"&lt;\" . \"script\" . \" type='text\/javascript'&gt; var oim=document.getElementById('mytopimage'); oim.src='http:\/\/www.rjmprogramming.com.au\/wordpress\/wp\" . $myr . \".jpg'; &lt;\/\" . \"script\" . \"&gt;\" . \"n\";<br \/>\n\t <b>if (($myr &gt;= 36 && $myr &lt; 40) || ($myr &gt;= 32 && $myr &lt; 33) || ($myr &gt;= 29 && $myr &lt; 30) || ($myr &gt;= 40 && $myr &lt; 42)) {<br \/>\n\t echo \"n\" . '&lt;style&gt;#mytopimage { mask: url(#m1); -webkit-border-bottom-left-radius: 200px; -webkit-border-bottom-right-radius: 200px; background-color: #fffff0; }&lt;\/style&gt;<br \/>\n&lt;svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" xmlns:xlink=\"http:\/\/www.w3.org\/1999\/xlink\" version=\"1.1\"  height=\"0\"&gt;<br \/>\n  &lt;mask id=\"m1\" maskUnits=\"objectBoundingBox\" maskContentUnits=\"objectBoundingBox\"&gt;<br \/>\n    &lt;!--linearGradient id=\"g\" gradientUnits=\"objectBoundingBox\" x2=\"0\" y2=\"1\"&gt;<br \/>\n      &lt;stop stop-color=\"#fffff0\" offset=\"0\"\/&gt;<br \/>\n      &lt;stop stop-color=\"#fffff0\" stop-opacity=\"0\" offset=\"1\"\/&gt;<br \/>\n    &lt;\/linearGradient--&gt;<br \/>\n    &lt;circle cx=\"0.50\" cy=\"0.55\" r=\"0.45\" id=\"circle\" fill=\"#fffff0\"\/&gt;<br \/>\n    &lt;!--rect x=\"0.5\" y=\"0.2\" width=\"0.5\" height=\"0.8\" fill=\"url(#g)\"\/--&gt;<br \/>\n  &lt;\/mask&gt;<br \/>\n&lt;\/svg&gt;' . \"n\";<br \/>\n\t  }<br \/>\n          }<br \/>\n?&gt;<\/b><br \/>\n<\/code><\/p>\n<p>There are great links for this topic area, but don't want to swamp you, so here is a good starting <a target=_blank title='SVG mask ideas' href='https:\/\/developer.mozilla.org\/en-US\/docs\/Applying_SVG_effects_to_HTML_content'>link<\/a> regarding this topic.<\/p>\n<p>We last talked about SVG with <a target=_blank href='#pjspt' title='PHP\/Javascript SVG Primer Tutorial'>PHP\/Javascript SVG Primer Tutorial<\/a> as shown below.<\/p>\n<p>This tutorial has a <i>\"resonance\"<\/i> with the <i>\"reveal\"<\/i> themed <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=9447' title='HTML\/Javascript Reveal Image Behind Image Primer Tutorial'>HTML\/Javascript Reveal Image Behind Image Primer Tutorial<\/a>.<\/p>\n<p>Finally, as far as Ajax contextual help goes, the recent <i>wajax.js<\/i> changed as per the bold code below, last talked about with <a target=_blank title='' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=10819'>WordPress Ajax Mobile Friendly Primer Tutorial<\/a>:<\/p>\n<p><code><br \/>\n<b><br \/>\nfunction getSVG(evt) {<br \/>\n   bpost = 10920;<br \/>\n   if ((wisiPad || wisTouch)) {<br \/>\n   if (mtimer) clearInterval(mtimer);<br \/>\n   tickcnt = 0;<br \/>\n   mtimer = setInterval(mchecker, 1000);<br \/>\n   } else {<br \/>\n   setTimeout(xget, 8000);<br \/>\n   }<br \/>\n}<br \/>\n<\/b><br \/>\nfunction winit() {<br \/>\n      var allPs;<br \/>\n      zhr = null;<br \/>\n      zok = 1;<br \/>\n      if ((wisiPad || wisTouch) || 1 == 1) {<br \/>\n        var mybased = document.getElementById('site-description');<br \/>\n        if (mybased.innerHTML.indexOf(\"Long \") == -1) {<br \/>\n        if ((wisiPad || wisTouch)) {<br \/>\n        mybased.innerHTML = mybased.innerHTML.replace(\")\", \") &lt;br&gt;&lt;a onclick=' alert(wadvice); ' href='#' title='Long touch contextual help'&gt;Long touch help available.&lt;\/a&gt;\");<br \/>\n        } else {<br \/>\n        mybased.innerHTML = mybased.innerHTML.replace(\")\", \") &lt;br&gt;&lt;a onclick=' alert(wadvice.replace(\"touch on\",\"hover over\")); ' href='#' title='Long hover contextual help'&gt;Long hover help available.&lt;\/a&gt;\");<br \/>\n        }<br \/>\n        }<br \/>\n      }<br \/>\n<b><br \/>\n      if (navigator.userAgent.toLowerCase().indexOf(\"ie\") != (0 - 1)) {<br \/>\n       allPs = document.getElementsByTagName('img');<br \/>\n      } else {<br \/>\n       allPs= document.getElementsByTagName('img');<br \/>\n      }<br \/>\n      for (var j=0; j &lt; allPs.length; j++) {<br \/>\n         if (allPs[j].id == \"mytopimage\") {<br \/>\n           if ((wisiPad || wisTouch)) {<br \/>\n           allPs[j].ontouchstart = getSVG;<br \/>\n           allPs[j].ontouchend = yehBut;<br \/>\n           } else {<br \/>\n           allPs[j].onmouseover = getSVG; \/\/ 10920<br \/>\n           if (allPs[j].title.indexOf(\" ...\") == -1) {<br \/>\n             allPs[j].title = allPs[j].title + \" ... welcome to the long hover functionality that shows Blog Post regarding SVG Mask\";<br \/>\n           }<br \/>\n           allPs[j].onmouseout = yehBut;<br \/>\n           }<br \/>\n         }<br \/>\n      }<br \/>\n<\/b><br \/>\n<\/code><\/p>\n<p>... to become <a target=_blank title='wajax.js' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/wajax.js---GETME'>wajax.js<\/a><\/p>\n<hr \/>\n<p id='pjspt'>Previous relevant <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=8614' title='PHP\/Javascript SVG Primer Tutorial'>PHP\/Javascript SVG Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/SVG\/\"><img decoding=\"async\" id=\"hjspt\" style=\"float:left;border: 15px solid pink;\" alt=\"PHP\/Javascript SVG Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/SVG\/SVG_Primer.png\" title=\"PHP\/Javascript SVG Primer Tutorial\"  onmouseover=\" document.getElementById('hjspt').src = document.getElementById('hjspt').src.replace('png','PNG').replace('jpg','png').replace('PNG','jpg');     \" \/><\/a><p class=\"wp-caption-text\">PHP\/Javascript SVG Primer Tutorial<\/p><\/div>\n<p>The HTML5 specification allows for the display of 2D-graphics via <a target=_blank href='http:\/\/www.tutorialspoint.com\/html5\/html5_svg.htm' title='SVG information'>SVG HTML tags<\/a> which use graphical applications in XML and the XML is then rendered by an SVG viewer.   SVG stands for Scalable Vector Graphics.<\/p>\n<p>We've talked about the HTML canvas element as another means to come to this end, but the SVG methods are more straightforward in their creation.<\/p>\n<p>For today's tutorial we follow the advice at this wonderful <a target=_blank href='http:\/\/www.tutorialspoint.com\/html5\/html5_svg.htm' title='SVG information'>tutorial<\/a> and wrap it in PHP, so that you can specify your own parameters.   Hope you find it very useful, and easy.<\/p>\n<p>This demonstrates to you that if you have some great static HTML you can keep that great static content and present a dynamic version the user can play around with, and learn from, by adding that PHP server-side content.   For today's PHP interface we got the HTML to use an HTML form of the relevant shape's characteristics and <i>post<\/i> this data back to the same PHP webpage, analyzing the $_POST[] data to fill in the static HTML parameter values with user-defined parameter alternatives.<\/p>\n<p>Today we have PHP and Javascript programmable source code you could call <a target=_blank title='SVG_Primer.php' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/SVG\/SVG_Primer.php_GETME'>SVG_Primer.php<\/a> and here is its <a target=_blank title='SVG_Primer.php' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/SVG\/SVG_Primer.php'>live run<\/a>.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#8614' onclick='var dv=document.getElementById(\"d8614\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=HTML5\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d8614' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#10920' onclick='var dv=document.getElementById(\"d10920\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=SVG\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d10920' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The HTML5 specification allows for the display of 2D-graphics via SVG HTML tags which use graphical applications in XML and the XML is then rendered by an SVG viewer. SVG stands for Scalable Vector Graphics. Those SVG shapes can be &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/wordpress-blog-custom-header-image-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,12,37],"tags":[69,151,275,276,281,282,578,751,798,931,932,997,1063,1073,1226,1319,1456],"class_list":["post-10920","post","type-post","status-publish","format-standard","hentry","category-ajax","category-elearning","category-tutorials","tag-ajax","tag-blog","tag-cross-browser","tag-cross-browser-issues","tag-css","tag-css3","tag-html5","tag-mask","tag-mobile-friendly","tag-photography","tag-php","tag-programming","tag-reveal","tag-rounded-border","tag-svg","tag-tutorial","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/10920"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=10920"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/10920\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=10920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=10920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=10920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}