-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: use scaled endpoint for nft images #308
Merged
Merged
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4d362e2
wip
goga-m baae8dd
style: resolve style guide violations
goga-m 7d4af45
wip
goga-m 50aa1b3
Merge branch 'develop' into refactor/scaled-nft-images
goga-m b540928
wip
goga-m 34bd392
style: resolve style guide violations
goga-m a1416c3
wip
goga-m db7cfd7
style: resolve style guide violations
goga-m 3e5fc18
Merge branch 'develop' into refactor/scaled-nft-images
goga-m a2d79ad
wip
goga-m a6e5cac
wip
goga-m 264ee3a
Merge branch 'develop' into refactor/scaled-nft-images
goga-m 94293e2
style: resolve style guide violations
goga-m da9c96d
wip
goga-m d5fde5e
Merge branch 'develop' into refactor/scaled-nft-images
goga-m 8b1da95
wip
goga-m 8fff4c2
Merge branch 'develop' into refactor/scaled-nft-images
goga-m 1a318b0
wip
goga-m 6f8b28a
Merge branch 'develop' into refactor/scaled-nft-images
goga-m 4c726fa
Merge branch 'develop' into refactor/scaled-nft-images
goga-m 0e169ed
Merge branch 'develop' into refactor/scaled-nft-images
goga-m fd84323
Merge branch 'develop' into refactor/scaled-nft-images
alfonsobries 78fa6d8
Merge branch 'develop' into refactor/scaled-nft-images
ItsANameToo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
database/migrations/2023_10_30_115558_update_nft_thumbnail_to_scaled.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
return new class() extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
|
||
DB::table('nfts')->get()->each(function ($nft) { | ||
$extraAttributes = json_decode($nft->extra_attributes); | ||
|
||
$previousThumb = $extraAttributes->images->thumb; | ||
$previousSmall = $extraAttributes->images->small; | ||
$previousLarge = $extraAttributes->images->large; | ||
|
||
$extraAttributes->images->thumb = $this->replaceThumbnailsWithScaled($extraAttributes->images->thumb); | ||
$extraAttributes->images->small = $this->replaceThumbnailsWithScaled($extraAttributes->images->small); | ||
$extraAttributes->images->large = $this->replaceThumbnailsWithScaled($extraAttributes->images->large); | ||
|
||
if ($previousThumb !== $extraAttributes->images->thumb || $previousSmall !== $extraAttributes->images->small || $previousLarge !== $extraAttributes->images->large) { | ||
DB::table('nfts') | ||
->where('id', $nft->id) | ||
->update(['extra_attributes' => json_encode($extraAttributes)]); | ||
} | ||
|
||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we make this a query to update the urls to |
||
} | ||
|
||
public function replaceThumbnailsWithScaled(string $url): string | ||
{ | ||
return preg_replace('/thumbnailv2/', 'scaled', $url); | ||
} | ||
}; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we update existing image urls by replacing it as such as well? if so, it would be good to add a migration that would update the existing NFTs so they are all using the new format