{"id":233,"date":"2012-04-03T09:04:47","date_gmt":"2012-04-03T16:04:47","guid":{"rendered":"http:\/\/www.wei-tek.com\/myblog\/?p=233"},"modified":"2016-06-16T13:27:12","modified_gmt":"2016-06-16T20:27:12","slug":"rotating-images-and-files-on-webpage","status":"publish","type":"post","link":"https:\/\/blog.wei-tek.com\/?p=233","title":{"rendered":"Rotating Images and Files on Webpage"},"content":{"rendered":"<p>Continue to work on getting my website updated.\u00a0 It is fun learning new things as I work on the site.\u00a0 \u00a0 Ive added rotating images to my pages as well as the background using the rotate.php script from Dan P. Benjamin, Automatic, Ltd. The script is very simple to implement copy the file into the directory with your images then call it from your page or from the css file to rotate the background. <a title=\"Link Dan Benjamin random image rotator\" href=\"http:\/\/www.alistapart.com\/articles\/randomizer\/\" target=\"_blank\">Dan P. Benjamin, Automatic, Ltd.\u00a0 random image rotator.<\/a> <strong>\u00a0<\/strong><\/p>\n<h2>Sample entry for css file:<\/h2>\n<p>background: url(images\/random-images\/rotate.php);<\/p>\n<h1>Sample entry for webpage:<\/h1>\n<p>&lt;p align=&#8221;center&#8221;&gt;&lt;img src=&#8221;images\/photography\/rotate.php&#8221; alt=&#8221;random photos&#8221; width=&#8221;375&#8243; height=&#8221;315&#8243; \/&gt;&lt;\/p&gt;<\/p>\n<p>To provide a random id for the images<!--more--> I set a variable using uniqid then generate a random number.\u00a0 Then add an id to the rotate.php.<\/p>\n<p><strong>Sample Variable for uniq id:<\/strong> \/*&lt;?php $ranzyz345 = md5( uniqid (rand(), 1) ); ?&gt;*\/<\/p>\n<p><strong>Sample adding uniq id to rotate.php:<\/strong> \/*&lt;img src=&#8221;images\/directory\/rotate.php?id=&lt;?php echo($ranzyz345); ?&gt;&#8221; title=&#8221;&#8221; alt=&#8221;Random Marine Corps Emblems and Cheverons&#8221; width=&#8221;125&#8243; height=&#8221;125&#8243; style=&#8221;float:left; padding-right: 10px; padding-left: 10px;&#8221; border=&#8221;1.0&#8243;\/&gt;*\/<\/p>\n<p>For\u00a0 rotating\u00a0 videos or other\u00a0 content\u00a0 randomly I use another php script that read a directory an randomly pulls files from the directory would love to give credit where this file came from but I can&#8221;t find it.\u00a0 But here\u00a0 is the code, the only change is enter the path to your directory.\u00a0 I setup a div then use\u00a0 a include to load the file into the page.<\/p>\n<p><strong>Code for random.php<\/strong> \/* error_reporting (E_ALL | E_STRICT); $files = array(); $path = &#8220;(path to\u00a0 directory)\/&#8221;; if( $handle = opendir( $path ) ) { while (false !== ($file = readdir($handle))) {\u00a0 if( $file != &#8220;.&#8221; &amp;&amp; $file != &#8220;..&#8221; &amp;&amp; !is_dir( $path.$file ) ) { $files[] = $path.$file; }*<strong>\/<\/strong><\/p>\n<p><strong>You need to populate the $files variable before you count it;<\/strong>\u00a0 \/*$file = $files[ rand( 0, count( $files ) -1 ) ];*\/<\/p>\n<p><strong>Now we can include it!<\/strong>\u00a0 \/*include (&#8220;$file&#8221;); } else { print &#8220;no files found&#8221;}*\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Continue to work on getting my website updated.\u00a0 It is fun learning new things as I work on the site.\u00a0 \u00a0 Ive added rotating images to my pages as well as the background using the rotate.php script from Dan P. Benjamin, Automatic, Ltd. The script is very simple to implement copy the file into the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18],"tags":[56,54,55],"class_list":["post-233","post","type-post","status-publish","format-standard","hentry","category-internet","tag-images","tag-php","tag-website"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Rotating Images and Files on Webpage - WEI-Tek Consulting Company Blog<\/title>\n<meta name=\"description\" content=\"How to use PHP and rotate images and file on your website.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.wei-tek.com\/?p=233\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Rotating Images and Files on Webpage - WEI-Tek Consulting Company Blog\" \/>\n<meta property=\"og:description\" content=\"How to use PHP and rotate images and file on your website.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.wei-tek.com\/?p=233\" \/>\n<meta property=\"og:site_name\" content=\"WEI-Tek Consulting Blog\" \/>\n<meta property=\"article:published_time\" content=\"2012-04-03T16:04:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-06-16T20:27:12+00:00\" \/>\n<meta name=\"author\" content=\"rainewalker\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rainewalker\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blog.wei-tek.com\\\/?p=233#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.wei-tek.com\\\/?p=233\"},\"author\":{\"name\":\"rainewalker\",\"@id\":\"https:\\\/\\\/blog.wei-tek.com\\\/#\\\/schema\\\/person\\\/57843d667045c1d2e92f6709b31826cc\"},\"headline\":\"Rotating Images and Files on Webpage\",\"datePublished\":\"2012-04-03T16:04:47+00:00\",\"dateModified\":\"2016-06-16T20:27:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blog.wei-tek.com\\\/?p=233\"},\"wordCount\":339,\"commentCount\":18,\"keywords\":[\"Images\",\"PHP\",\"Website\"],\"articleSection\":[\"Internet\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blog.wei-tek.com\\\/?p=233#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blog.wei-tek.com\\\/?p=233\",\"url\":\"https:\\\/\\\/blog.wei-tek.com\\\/?p=233\",\"name\":\"Rotating Images and Files on Webpage - WEI-Tek Consulting Company Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.wei-tek.com\\\/#website\"},\"datePublished\":\"2012-04-03T16:04:47+00:00\",\"dateModified\":\"2016-06-16T20:27:12+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blog.wei-tek.com\\\/#\\\/schema\\\/person\\\/57843d667045c1d2e92f6709b31826cc\"},\"description\":\"How to use PHP and rotate images and file on your website.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blog.wei-tek.com\\\/?p=233#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blog.wei-tek.com\\\/?p=233\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blog.wei-tek.com\\\/?p=233#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/blog.wei-tek.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Rotating Images and Files on Webpage\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blog.wei-tek.com\\\/#website\",\"url\":\"https:\\\/\\\/blog.wei-tek.com\\\/\",\"name\":\"WEI-Tek Consulting Blog\",\"description\":\"Tip, Tricks and Letting off steam\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blog.wei-tek.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blog.wei-tek.com\\\/#\\\/schema\\\/person\\\/57843d667045c1d2e92f6709b31826cc\",\"name\":\"rainewalker\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d680e5f042d634a22d17592d61565cd82ae4b89c745ba619c1d8e796fb79b89?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d680e5f042d634a22d17592d61565cd82ae4b89c745ba619c1d8e796fb79b89?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d680e5f042d634a22d17592d61565cd82ae4b89c745ba619c1d8e796fb79b89?s=96&d=identicon&r=g\",\"caption\":\"rainewalker\"},\"sameAs\":[\"http:\\\/\\\/www.my-businessmail.com\"],\"url\":\"https:\\\/\\\/blog.wei-tek.com\\\/?author=2\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Rotating Images and Files on Webpage - WEI-Tek Consulting Company Blog","description":"How to use PHP and rotate images and file on your website.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.wei-tek.com\/?p=233","og_locale":"en_US","og_type":"article","og_title":"Rotating Images and Files on Webpage - WEI-Tek Consulting Company Blog","og_description":"How to use PHP and rotate images and file on your website.","og_url":"https:\/\/blog.wei-tek.com\/?p=233","og_site_name":"WEI-Tek Consulting Blog","article_published_time":"2012-04-03T16:04:47+00:00","article_modified_time":"2016-06-16T20:27:12+00:00","author":"rainewalker","twitter_misc":{"Written by":"rainewalker","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.wei-tek.com\/?p=233#article","isPartOf":{"@id":"https:\/\/blog.wei-tek.com\/?p=233"},"author":{"name":"rainewalker","@id":"https:\/\/blog.wei-tek.com\/#\/schema\/person\/57843d667045c1d2e92f6709b31826cc"},"headline":"Rotating Images and Files on Webpage","datePublished":"2012-04-03T16:04:47+00:00","dateModified":"2016-06-16T20:27:12+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.wei-tek.com\/?p=233"},"wordCount":339,"commentCount":18,"keywords":["Images","PHP","Website"],"articleSection":["Internet"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.wei-tek.com\/?p=233#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.wei-tek.com\/?p=233","url":"https:\/\/blog.wei-tek.com\/?p=233","name":"Rotating Images and Files on Webpage - WEI-Tek Consulting Company Blog","isPartOf":{"@id":"https:\/\/blog.wei-tek.com\/#website"},"datePublished":"2012-04-03T16:04:47+00:00","dateModified":"2016-06-16T20:27:12+00:00","author":{"@id":"https:\/\/blog.wei-tek.com\/#\/schema\/person\/57843d667045c1d2e92f6709b31826cc"},"description":"How to use PHP and rotate images and file on your website.","breadcrumb":{"@id":"https:\/\/blog.wei-tek.com\/?p=233#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.wei-tek.com\/?p=233"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog.wei-tek.com\/?p=233#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.wei-tek.com\/"},{"@type":"ListItem","position":2,"name":"Rotating Images and Files on Webpage"}]},{"@type":"WebSite","@id":"https:\/\/blog.wei-tek.com\/#website","url":"https:\/\/blog.wei-tek.com\/","name":"WEI-Tek Consulting Blog","description":"Tip, Tricks and Letting off steam","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.wei-tek.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.wei-tek.com\/#\/schema\/person\/57843d667045c1d2e92f6709b31826cc","name":"rainewalker","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4d680e5f042d634a22d17592d61565cd82ae4b89c745ba619c1d8e796fb79b89?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4d680e5f042d634a22d17592d61565cd82ae4b89c745ba619c1d8e796fb79b89?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4d680e5f042d634a22d17592d61565cd82ae4b89c745ba619c1d8e796fb79b89?s=96&d=identicon&r=g","caption":"rainewalker"},"sameAs":["http:\/\/www.my-businessmail.com"],"url":"https:\/\/blog.wei-tek.com\/?author=2"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2SXof-3L","_links":{"self":[{"href":"https:\/\/blog.wei-tek.com\/index.php?rest_route=\/wp\/v2\/posts\/233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.wei-tek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wei-tek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wei-tek.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wei-tek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=233"}],"version-history":[{"count":1,"href":"https:\/\/blog.wei-tek.com\/index.php?rest_route=\/wp\/v2\/posts\/233\/revisions"}],"predecessor-version":[{"id":322,"href":"https:\/\/blog.wei-tek.com\/index.php?rest_route=\/wp\/v2\/posts\/233\/revisions\/322"}],"wp:attachment":[{"href":"https:\/\/blog.wei-tek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wei-tek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wei-tek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}