in case someone wants to use imageflow from simplest gallery just like me, here is the code of sg-imageflow.php I altered. You don’t need to install simple gallery at all this way. only the altered imageflow plugin.
imageflow gallery is used only if you add type in the shortcode:
[gallery type="imageflow" ]
sg-imageflow.php:
<?php
/*
Plugin Name: Imageflow for Simplest Gallery
Version: 1.1
Plugin URI: https://www.simplestgallery.com/add-ons/
Description: Display your WordPress galleries as an Imageflow with reflected images. Requires the "Simplest Gallery" plugin (adds a new gallery style to it).
Author: Cristiano Leoni
Author URI: https://www.linkedin.com/pub/cristiano-leoni/2/b53/34
# This file is UTF-8 - These are accented Italian letters aeiou
Includes software by Finn Rudolph, Ralf Hettinger, Richard Davey, Monte Ohrt et al.
*/
/*
History
+ 1.1 2014-06-26 Fix to avoid problems in the page (div ID renamed and line breaks removed)
+ 1.0 2013-04-29 First working version
*/
/** plugin code **/
function imageflow_gallery_enqueue() {
if (isTimeToLoadImageflowGallery()) {
global $wp_styles;
$imageflow_gallery_plugin_prefix = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
// add javascript to head
wp_enqueue_script('imageflow_gallery-1.2.1', ($imageflow_gallery_plugin_prefix.'/imageflow/imageflow.js'), false, '1.2.1');
// add css to head
wp_enqueue_style('imageflow_gallery_style-1.2.1', ($imageflow_gallery_plugin_prefix . '/imageflow/imageflow.css'));
}
}
function imageflow_gallery_shortcode($output, $attr) {
if (!isTimeToLoadImageflowGallery()) return $output;
if (isset($attr['type']) && $attr['type']=="imageflow")
{
global $post, $wp_locale;
// We're trusting author input, so let's at least make sure it looks like a valid orderby statement
if ( isset( $attr['orderby'] ) ) {
$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
if ( !$attr['orderby'] ) {
unset( $attr['orderby'] );
}
}
extract(shortcode_atts(array(
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post->ID,
'itemtag' => '',
'icontag' => '',
'captiontag' => '',
'columns' => 3,
'size' => 'thumbnail',
'include' => '',
'exclude' => ''
), $attr));
$image_size = get_option('image_size', 'medium');
$ignore_columns = get_option('ignore_columns', 'no');
$thumbnail_caption = get_option('thumbnail_caption', 'show');
$id = intval($id);
if ( 'RAND' == $order ) {
$orderby = 'none';
}
if ( !empty($include) ) {
$include = preg_replace( '/[^0-9,]+/', '', $include );
$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
$attachments = array();
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif ( !empty($exclude) ) {
$exclude = preg_replace( '/[^0-9,]+/', '', $exclude );
$attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
} else {
$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
}
if ( empty($attachments) ) {
return '';
}
if ( is_feed() ) {
$output = "\n";
foreach ( $attachments as $att_id => $attachment ) {
$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
}
return $output;
}
$output = makeImageflowGalleryForPCandTablets($attachments, $thumbnail_caption, $id, $image_size, $ignore_columns, $columns);
return $output;
}
}
function makeImageflowGalleryForPCandTablets($attachments, $thumbnail_caption, $id, $image_size, $ignore_columns, $columns){
$html_id="ImageFlow_".$id;
$pluginpath = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
$siteurl = get_bloginfo('url');
$startShot = intval(count($attachments)/2)+1;
$showDesc = FALSE;
$reflectColor = 'ffffff';
$output .= '
<div id="imageflow_left"><script type="text/javascript" defer="defer">
domReady(function() {
var instance1 = new ImageFlow();
instance1.init({
ImageFlowID:\''.$html_id.'\'
, onClick: \'\'
, preloadImages: false
, reflectionGET: \'&bgc='.$reflectColor.'\'
, startID: '.$startShot.'
});
});
</script><div id="'.$html_id.'" class="imageflow">';
$count=0;
foreach ($attachments as $id => $attachment) {
$im = wp_get_attachment_image_src($id, $size=$image_size, $icon = false);
$htmlcaption=wptexturize(trim($attachment->post_title));
$reflect_url = $pluginpath.'/reflect2.php?img='.str_replace(sgif_selfServer(),'',$im[0]).'&bgc='.$reflectColor;
$output .= '<img src="'.$reflect_url.'" longdesc="'.($showDesc?$htmlcaption:'').'" alt="'.($showDesc?$htmlcaption:'').'" title="'.$htmlcaption.'" />';
$count++;
}
$output .= '</div><!-- /imageflow_left -->';
return $output;
}
function sgif_selfServer() {
$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
$protocol = sgif_strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
return $protocol."://".$_SERVER['SERVER_NAME'].$port;
}
function sgif_strleft($s1, $s2) {
return substr($s1, 0, strpos($s1, $s2));
}
function isTimeToLoadImageflowGallery(){
$show_in_pages = (get_option('show_in_pages', 'yes') === 'yes');
return (!is_admin() AND ($show_in_pages OR is_single() OR is_feed()));
}
add_action('wp_enqueue_scripts', 'imageflow_gallery_enqueue');
//Shortcode
add_filter('post_gallery', 'imageflow_gallery_shortcode', 10, 2);
?>