Skip to content
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

Block-Editor Sidebar Image Size Select Issue #65

Open
ouun opened this issue Oct 11, 2022 · 6 comments
Open

Block-Editor Sidebar Image Size Select Issue #65

ouun opened this issue Oct 11, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@ouun
Copy link
Contributor

ouun commented Oct 11, 2022

Changing the Image Size from the Block Options panel uses the wrong image url.

2Kapture 2022-10-11 at 12 22 27

@robindevitt
Copy link
Contributor

Hey @ouun thanks for reporting this bug. I haven't been able to replicate the issue myself. Please may you provide some details that can assist in replicating the issue?

@robindevitt robindevitt added the bug Something isn't working label Oct 12, 2022
@ouun
Copy link
Contributor Author

ouun commented Oct 12, 2022

Hi @robindevitt,
thanks for getting back to me. I am using AMF together with Tachyon (humanmade/tachyon-plugin) & Smart Media (humanmade/smart-media). Now thinking about that again, I might have ended in the wrong repo for this report.

The issue is that using the switch replaces the img src with the default links that have the size as suffix. E.g. filename-1200x500.jpg. But it should be the original filename with the requested size as parameters: filename.jpg?w=1200&h=500

This is Tachyon related, isn't it? If yes, please let me know and I will close the ticket here and reopen it at the othe repo.

Thanks! :)

@robindevitt
Copy link
Contributor

@ouun I have tried testing this further from my side, however I haven't been able to replicate your bug yet.

amf-bug-65

Can you confirm the versions of of AMF, Tachyon and Smart Media you are using so I can try replicate the bug? As well as potential info of your install/ setup.

We can always move this issue to the appropriate repo once the bug is able to be replicated.

@ouun
Copy link
Contributor Author

ouun commented Oct 12, 2022

Strange. The versions I am using seem to be the most up-to-date:

AMF: 0.13.4
Tachyon: 0.11.5
Smart Media: 0.4.3

I am loading tachyon and smart-media right after each other very similiar to this: https://github.com/humanmade/altis-media/blob/98aa4941aea7a7b7a558129a1fc577f1259a6a5f/inc/namespace.php#L41

Clicking on the block option "replace" and choosing another image size in the media modal works as expected.
So it currently seems to me, that for the select field the used Rest API output is not modified correctly. I approved that by logging the output of $data['media_details']['sizes'] here: https://github.com/humanmade/smart-media/blob/d5e22269200b41aaf480b20c469b5fbd9aa7a56f/inc/cropper/namespace.php#L176

Using the "replace" button and choosing another image size from the media library (Smart Media UI) outputs the correct image URLs such as /image.jpg?fit=1024%2C1024. However in the Rest API response, the image URLs logged from $data['media_details']['sizes'] are the regular WordPress /image-1024x500.jpg.

Hope that helps and thanks a lot again!

@ouun
Copy link
Contributor Author

ouun commented Oct 12, 2022

@robindevitt I found the issue, please stop debugging! It is produced by a filter I added a while ago:

    // Support wp_get_attachment_url usage for images
    if (!is_admin()) {
        add_filter('wp_get_attachment_url', function ($url, $attachment_id) {
            // Rewrite Image URLs to Tachyon Endpoint
            if (wp_attachment_is_image($attachment_id) && get_post_mime_type($attachment_id) !== 'image/svg+xml') {
                return tachyon_url($url);
            }

            return $url;
        }, 10, 2);
    }

I am using the above to modify/fix image URLs that are not handled via Tachyon by default, as my theme uses "wp_get_attachment_url()" to reference images. Any idea how to keep that filter intact while not breaking other parts?

Thanks and kind regards!

@robindevitt
Copy link
Contributor

Hey @ouun

Great to hear!

By default the plugin handles the following extensions

  • gif
  • jpg
  • jpeg
  • png
  • webp

This would imply that the SVG's wont be included through Tachyon.

If you removed the filter does that not give you the desired result?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants