Created
April 12, 2019 22:08
-
-
Save logoscreative/8ba836ce4a1e9695c566f97b991957b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Envira CDN Fix | |
* Plugin URI: https://logoscreative.com | |
* Description: Support images on a CDN with Envira | |
* Version: 1.0 | |
* Author: Logos Creative | |
* Author URI: https://logoscreative.com | |
*/ | |
add_filter('envira_gallery_output', 'evermore_filter_envira_content', 10, 2); | |
add_filter('envira_gallery_link_href', 'evermore_filter_envira_link_href', 10, 5); | |
add_filter('envira_gallery_pre_data', 'evermore_envira_cdn_compat', 10, 2); | |
function evermore_filter_envira_content($gallery, $data) | |
{ | |
if (isset($_GET['cliffdebug']) && $_GET['cliffdebug'] === 'sure') { | |
//var_dump($gallery); | |
//var_dump($data); | |
} | |
return apply_filters('as3cf_filter_post_local_to_s3', $gallery); | |
} | |
function evermore_filter_envira_link_href($id, $item, $data, $i, $mobile) | |
{ | |
if (isset($_GET['cliffdebug']) && $_GET['cliffdebug'] === 'sure') { | |
var_dump($item); | |
var_dump($data); | |
} | |
//return apply_filters( 'as3cf_filter_post_local_to_s3', $gallery ); | |
} | |
function evermore_envira_cdn_compat($data, $gallery_id) | |
{ | |
$images = $data['gallery']; | |
foreach ($images as $attachment_id => $image) { | |
if ($image['src']) { | |
$data['gallery'][$attachment_id]['src'] = apply_filters('as3cf_filter_post_local_to_s3', $image['src']); | |
} | |
if ($image['thumb']) { | |
$data['gallery'][$attachment_id]['thumb'] = apply_filters('as3cf_filter_post_local_to_s3', $image['thumb']); | |
} else { | |
$data['gallery'][$attachment_id]['thumb'] = apply_filters('as3cf_filter_post_local_to_s3', wp_get_attachment_thumb_url($attachment_id)); | |
} | |
} | |
if (isset($_GET['cliffdebug']) && $_GET['cliffdebug'] === 'sure') { | |
var_dump($data); | |
} | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment