Shutting down my image host. The most popular feature was my randomizer. I thought I'd share the code so you can add it to your site! Please let me know if you decide to use and and what website! My users are looking for a new home (10k+).
Please note this is for v3. This was set up for htaccess/apache servers. If you use nginx please modify it for your server. I am too busy at this time and cannot provide support.
Step one:
Create a subdomain such as
random.yourhost.com
The PHP code. Save this in a file called i.php
Go to your Chevereto Themes and in the overrides for views/album.php (located in app/themes/Peafowl) look for the share snippet and add the following:
Go to overrides/snippets and create a new file called modal_random.php and use this code
Last part is your .htaccess
RewriteEngine on
RewriteRule ^(.+)\.gif$ https://random.yourhost.com/i.php?id=$1 [R=301,L]
Please note this is for v3. This was set up for htaccess/apache servers. If you use nginx please modify it for your server. I am too busy at this time and cannot provide support.
Step one:
Create a subdomain such as
random.yourhost.com
The PHP code. Save this in a file called i.php
PHP:
$servername = "localhost";
$username = "myusername";
$password = "mypassword";
$dbname = "mydatabase";
$id = intval($_GET['id']);
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT CONCAT('https://cdn.yourhost.host/',`image_name`, '.', `image_extension`) AS random_image FROM `chv_images` WHERE `image_album_id` = ".$id." ORDER BY RAND() LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$ranURL = $row["random_image"];
header ('Location: '.$ranURL);
}
} else {
echo "doesnt exist";
}
$conn->close();
Go to your Chevereto Themes and in the overrides for views/album.php (located in app/themes/Peafowl) look for the share snippet and add the following:
PHP:
<a class="btn blue" data-modal="simple" data-target="modal-random"><span class="icon fas fa-random"></span><span class="btn-text phone-hide">Randomizer</span></a>
<?php G\Render\include_theme_file('snippets/modal_random'); ?>
Go to overrides/snippets and create a new file called modal_random.php and use this code
PHP:
<?php if(!defined('access') or !access) die('This file cannot be directly accessed.'); ?> <?php $share_modal = function_exists('get_share_modal') ? get_share_modal() : G\get_global("share_modal"); ?> <div id="modal-random" class="hidden"> <span class="modal-box-title">Randomizer</span> <p class="highlight margin-bottom-20 font-size-small text-align-center<?php if(is_null($share_modal["privacy"]) || $share_modal["privacy"] == "public") echo " soft-hidden"; ?>" data-content="privacy-private"><?php echo $share_modal['privacy_notes']; ?></p> Below you can grab your randomizer link! All album images in this album will be in the randomizer. You can add or remove images from the album at any time to effect the randomizer. <div class="c8 phablet-c1"> <div class="input-label margin-bottom-0"> <label for="modal-share-url"><?php _se('Link'); ?></label> <input type="text" name="modal-random-url" id="modal-random-url" class="text-input" value="https://random.yourhost.com/<?php $RanAlbumID = get_album()['id']; echo $RanAlbumID; ?>.gif" data-focus="select-all"> </div> </div> </div>
Last part is your .htaccess
RewriteEngine on
RewriteRule ^(.+)\.gif$ https://random.yourhost.com/i.php?id=$1 [R=301,L]
Last edited: