Changeset 3088944
- Timestamp:
- 05/19/2024 10:59:11 AM (23 months ago)
- Location:
- nft-gallery/tags/1.3.0
- Files:
-
- 2 edited
-
inc/shortcodes.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
nft-gallery/tags/1.3.0/inc/shortcodes.php
r3087315 r3088944 6 6 * you will find all functions related to the shortcodes that are available on the plugin. 7 7 * 8 * @author Hendra Setiawan9 * @version 1. 0.08 * @authors Hendra Setiawan, Nick Weisser 9 * @version 1.3.0 10 10 */ 11 11 … … 33 33 34 34 if ($type == 'owner') { 35 $request = wp_remote_get('https://api.opensea.io/api/v2/chain/ethereum/account/'.$id.'/nfts ', $args);35 $request = wp_remote_get('https://api.opensea.io/api/v2/chain/ethereum/account/'.$id.'/nfts?limit='.$limit, $args); 36 36 } else { 37 $request = wp_remote_get('https://api.opensea.io/api/v2/collection/'.$id.'/nfts ', $args);37 $request = wp_remote_get('https://api.opensea.io/api/v2/collection/'.$id.'/nfts?limit='.$limit, $args); 38 38 } 39 39 … … 52 52 $nfts .= '<div class="row nftgallery">'; 53 53 foreach( $data->nfts as $asset ) { 54 $image_headers = @get_headers($asset->image_url, 1); 55 if ($image_headers === false) { continue; } 56 if (isset($image_headers['Content-Type']) && strpos($image_headers['Content-Type'], 'video') !== false) { 57 continue; // Skip this iteration if the content type is a video 58 } 59 // IPFS images with parentheses wouldn't render ... 60 // Parse URL 61 $parsed_url = parse_url($asset->image_url); 62 if ($parsed_url === false) { 63 echo "<!-- Failed to parse URL: {$asset->image_url} -->\n"; 64 continue; 65 } 66 // Manually encode the path 67 $encoded_path = implode('/', array_map('rawurlencode', explode('/', $parsed_url['path']))); 68 // Rebuild the URL 69 $encoded_image_url = $parsed_url['scheme'] . '://' . $parsed_url['host'] . $encoded_path; 70 71 // Replace ipfs.io with Cloudflare's IPFS gateway for caching 72 $image_url = str_replace('https://ipfs.io/ipfs/', 'https://cloudflare-ipfs.com/ipfs/', $encoded_image_url); 73 54 74 if($asset->name) { $title = $asset->name; } else { $title = '#'.$asset->identifier; } 55 75 56 76 $nfts .= '<div class="col-xs-6 col-sm-6 col-md-6 col-lg-4 nftgallery-wrapper">'; 57 77 $nfts .= '<div class="nft" data-url="'.$asset->opensea_url.'">'; 58 $nfts .= '<div class="image" style="background-image: url( '.$asset->image_url.');"></div>';78 $nfts .= '<div class="image" style="background-image: url(\''.$image_url.'\');"></div>'; 59 79 $nfts .= '<div class="desc"> 60 80 <div class="collection">'.$asset->collection.'</div> … … 84 104 $no = 1; 85 105 foreach( $data->nfts as $asset ) { 106 $image_headers = @get_headers($asset->image_url, 1); 107 if ($image_headers === false) { continue; } 108 if (isset($image_headers['Content-Type']) && strpos($image_headers['Content-Type'], 'video') !== false) { 109 continue; // Skip this iteration if the content type is a video 110 } 86 111 $basename = basename($asset->image_url); 87 112 if($asset->name) { $title = $asset->name; } else { $title = $asset->identifier; } -
nft-gallery/tags/1.3.0/readme.txt
r3088492 r3088944 53 53 == Changelog == 54 54 55 = 1.3.0 = 56 * Adds support for OpenSea API v2 57 * Converts ipfs.io to cloudflare-ipfs.com image URLs for caching 58 55 59 = 1.2.0 = 56 60 * Fixed : Images were not showing on Grid mode.
Note: See TracChangeset
for help on using the changeset viewer.