• Resolved twogee

    (@twogee)


    Hi,

    attachment pages have wrong sizes for SVG with the latest plugin. Here’s the code

    <img width="1" height="1" src="/wp-content/uploads/2016/01/logo.svg" class="attachment-large size-large" alt="" />

    In admin mode, theme customisation menu (site icon) and media library attachment detail popups cannot display SVG at all, only generic icon is shown.

    Could you please fix this? Thanks in advance.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Benbodhi

    (@benbodhi)

    Hello,

    Firstly, thanks for your support!

    The update to 2.2.4 shouldn’t affect any of this, it was just a single function added to deal with WordPress core changes to the way files are uploaded.

    For the theme customizer, please check this article: Using SVG logos with the WordPress Customizer.

    I’ll look into the generic icon being shown in media library attachment detail popups as soon as possible.

    Thread Starter twogee

    (@twogee)

    Thanks for prompt reply! I cannot verify whether <img width="1" height="1" .../> is an older issue, but I would like to understand where it comes from.

    I do not want to specify width and height in SVG explicitly, and adding custom logo with flex dimensions in functions.php seems to be insufficient: width and height must be larger than viewbox dimensions as well in order to avoid cropping.

    I suspect that generic icons in customizer and attachment detail are related; hope you will have time to investigate that soon.

    Plugin Author Benbodhi

    (@benbodhi)

    Hey @twogee,

    I have updated the plugin (2.2.5) to display SVG files in the attachment modal. You can not edit SVG images like other images so the “Edit Image” button is useless and will say there is no image to edit.

    When it comes to using SVG in the customizer, you need to add theme support like in the article mentioned so there is a “Skip Cropping” button, otherwise you’re stuck with a crop image button that will not work.

    I hope this helps.

    Thread Starter twogee

    (@twogee)

    Cool, thanks! As I thought, fixing the modal fixes the customizer ??

    Now, where does that height="1" width="1" on attachment page comes from? I’ll gladly fix that in the theme, even though I suspect it’s WP not finding explicit height/width and disregarding the viewport…

    Plugin Author Benbodhi

    (@benbodhi)

    When you say attachment pages, do you mean when viewing the full image URL in a browser window, outside the website itself?

    Plugin Author Benbodhi

    (@benbodhi)

    Nevermind, I see what you mean, when you click “view attachment page” from the media window.
    I’ll look into a fix for that.

    • This reply was modified 7 years, 10 months ago by Benbodhi.
    Plugin Author Benbodhi

    (@benbodhi)

    For now, I would suggest just using CSS to set the width and height of the SVG on it’s attachment page.
    May I ask when/how you actually use these attachment pages?

    Plugin Author Benbodhi

    (@benbodhi)

    This CSS should sort out the display of the SVG in attachment pages:

    
    .attachment img[src$=".svg"] {
    	width: 100%;
    }
    

    I’m about to release a new version with a bunch of new features, so I will look to include this CSS also.

    Thread Starter twogee

    (@twogee)

    Sweet, I was digging in wp_get_attachment_image_src and further into getimagesize in PHP ??

    I needed to change .attachment into .attachment-large, but the effect was that it kept width=1 and allowed height to rescale (to something even smaller), rather than inheriting width from parent div which would have given the expected effect.

    Plugin Author Benbodhi

    (@benbodhi)

    This issue is fixed in version 2.3 which I’m about to release in the next 10 minutes ??

    Thanks for your support!

    Thread Starter twogee

    (@twogee)

    Thank you – great job! “Advanced mode” is a bit scary, though ?? Why not calling it “inline mode”; also, what is the effect of it on the theme that already does file_get_contents( get_attached_file( get_theme_mod( 'custom_logo' ) ) )?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Wrong attachment pages with 2.2.4’ is closed to new replies.