Created
October 26, 2025 07:38
-
-
Save Firsh/14db23e2811cf9762f96169fbd6c6efd to your computer and use it in GitHub Desktop.
JIG Flickr Video Override Snippet
This file contains hidden or 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 | |
| /** | |
| * JIG Flickr Video Override Snippet | |
| * | |
| * This snippet overrides specific Flickr image links to point to external videos | |
| * that can be played by JIG's video player. | |
| * | |
| * Usage: Add this code to your functions.php or a snippets plugin. | |
| */ | |
| add_filter('jig_images_before_postprocessing', 'jig_flickr_video_override', 10, 2); | |
| function jig_flickr_video_override($images, $atts) { | |
| // Configuration: Map Flickr photo IDs to video URLs | |
| $flickr_video_overrides = array( | |
| // Add your mappings here: | |
| // 'FLICKR_PHOTO_ID' => 'VIDEO_URL', | |
| // Example: | |
| // '12345678901' => 'https://example.com/video.mp4', | |
| // '98765432101' => 'https://vimeo.com/123456789', | |
| '54812331783' => 'https://justifiedgrid.com/wp-content/uploads/5151177.mp4', | |
| //'54812331783' => 'https://www.youtube.com/watch?v=fc4fc72e6XI', | |
| ); | |
| // Process each image in the grid | |
| foreach ($images as &$image) { | |
| // Check if this is a Flickr image with the contentID pattern | |
| if (isset($image['extra_class']) && strpos($image['extra_class'], 'jig-contentID-FL-') === 0) { | |
| // Extract the Flickr photo ID from the class | |
| $flickr_id = str_replace('jig-contentID-FL-', '', $image['extra_class']); | |
| // Check if we have a video override for this Flickr ID | |
| if (isset($flickr_video_overrides[$flickr_id])) { | |
| $video_url = $flickr_video_overrides[$flickr_id]; | |
| // Override the link to point to the video | |
| $image['link'] = $video_url; | |
| // Determine link target based on video type | |
| if (stripos($video_url, 'youtube.com/watch') !== false | |
| || stripos($video_url, 'youtu.be') !== false | |
| || stripos($video_url, 'vimeo.com') !== false) { | |
| // Use 'video' target for YouTube/Vimeo - lightboxes handle these natively | |
| $image['link_target'] = 'video'; | |
| } else { | |
| // Use 'videoplayer' target for self-hosted videos - needs JIG's video player | |
| $image['link_target'] = 'videoplayer'; | |
| } | |
| // Optional: Add a custom class to identify video-overridden images | |
| $image['extra_class'] .= ' jig-video-override'; | |
| } | |
| } | |
| } | |
| return $images; | |
| } | |
| /** | |
| * Example usage with hardcoded Flickr ID (as requested): | |
| * | |
| * To override a specific Flickr photo, add an entry to the $flickr_video_overrides array above. | |
| * For example, if you want to override Flickr photo ID "53285473405" to point to a video: | |
| * | |
| * $flickr_video_overrides = array( | |
| * '53285473405' => 'https://example.com/path/to/your/video.mp4', | |
| * ); | |
| * | |
| * The video URL should be a direct link to a video file (mp4, webm, etc.) or a supported | |
| * video service URL (YouTube, Vimeo, etc.) that JIG can handle in its video player. | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment