Migrating to WordPress
-
I am relatively new to WordPress and am in the process of changing several sites over from to this platform. One site I have uses a bit of code in in my current index.php to control uploaded images from my webcam. I am not sure where to place this code in the WordPress structure.
The webcam uploads a photo every 30 seconds and each photo has a time stamp so this code is used to delete older photos and rename the most recent photo so the website can display the most up to date image. I image a plugin would be best bet, but haven’t found one so need to find how and where to insert this code.
the code in question in index.php is:
<!-- PHP to fix web cam images --> <?php // Run from on directory above your FI... directory // Change the next line for your snap directory chdir ('webcamsandlinks/images/FI9900P_00626E6A54A2/snap'); $files = glob('*.jpg'); // Exit if there is not a new snapshot file if(count($files) < 1){ return 0; } // Grab the first file and timestamp $file = array_shift( $files); $mTime = filemtime( $file); // Check the other files and delete if older foreach($files as $currFile){ $currTime = filemtime($currFile); if( $currTime > $mTime){ unlink($file); $file = $currFile; $mTime = $currTime; } else {unlink($currFile); } } // Only the newest file remains // Rename the snapshot file using the first 8 chars rename($file, substr($file, 0, 8) . '.jpg'); ?> <!-- End PHP -->
The topic ‘Migrating to WordPress’ is closed to new replies.