Edit Gallery Images Json (Fotorama on Product Pages)

I’m trying to remove duplicate product images/thumbnails from rendering on the product pages.

Currently overriding product/view/gallery.phtml, grabbing $block->getGalleryImagesJson() early on, decoding the JSON, unsetting elements with duplicate images, and then re-encoding.

Printing the new re-encoded shows that it’s the data I need, so I’m confused as to why replacing $block->getGalleryImagesJson() with the new JSON in the gallery script isn’t working?