Plugin Directory

Changeset 3088944


Ignore:
Timestamp:
05/19/2024 10:59:11 AM (23 months ago)
Author:
openstream
Message:

Repeats same changes in tags/1.3.0 sub-directory to be reflected on WordPress.org

Location:
nft-gallery/tags/1.3.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nft-gallery/tags/1.3.0/inc/shortcodes.php

    r3087315 r3088944  
    66* you will find all functions related to the shortcodes that are available on the plugin.
    77*
    8 * @author   Hendra Setiawan
    9 * @version  1.0.0
     8* @authors   Hendra Setiawan, Nick Weisser
     9* @version  1.3.0
    1010*/
    1111
     
    3333
    3434        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);
    3636        } 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);
    3838        }
    3939       
     
    5252                    $nfts .= '<div class="row nftgallery">';
    5353                    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
    5474                        if($asset->name) { $title = $asset->name; } else { $title = '#'.$asset->identifier; }
    55                        
     75
    5676                        $nfts .= '<div class="col-xs-6 col-sm-6 col-md-6 col-lg-4 nftgallery-wrapper">';
    5777                            $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>';
    5979                            $nfts .= '<div class="desc">
    6080                                        <div class="collection">'.$asset->collection.'</div>
     
    84104                    $no = 1;
    85105                    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                        }
    86111                        $basename = basename($asset->image_url);
    87112                        if($asset->name) { $title = $asset->name; } else { $title = $asset->identifier; }
  • nft-gallery/tags/1.3.0/readme.txt

    r3088492 r3088944  
    5353== Changelog ==
    5454
     55= 1.3.0 =
     56* Adds support for OpenSea API v2
     57* Converts ipfs.io to cloudflare-ipfs.com image URLs for caching
     58
    5559= 1.2.0 =
    5660* Fixed : Images were not showing on Grid mode.
Note: See TracChangeset for help on using the changeset viewer.