• Good morning,

    I am experiencing a usability issue with WordPress ever since the new editor was introduced. When I am in a “classic” block with text, e.g., “Documents: ” (note the space at the end; this is where the cursor is) and click “Add Media”, after inserting a link via “Insert into page”, the space is deleted and the text becomes “Documents:Link”. If I add a second space before inserting, one of the spaces is deleted. This behavior is counterintuitive – I would expect the “Add Media” action not to delete anything in the text that I typed. I use the most recent version of WordPress, but the issue persists since the new editor was introduced. How can this behavior be disabled or fixed?

    Thanks for your help
    Best
    Dust Signs

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Generally speaking, spaces in between different elements are ignored in HTML anyway. Which may explain the behavior you’re seeing.

    Basically, this:

    <p>this is a paragraph</p>

    Is functionally the same thing as this:

    <p>this
    is
    a
    paragraph
    </p>
    

    In HTML, they both render the same. Now, adding spaces between differing elements like when you switch from a <p> to an <img>, for example, the spaces are ignored, or rather, no matter how many spaces you put there, it’s just one space to HTML.

    So, by and large, I would expect some parts of the editor to delete or cleanup spacing when inserting new elements. It may not be 100% accurate as you are using the older classic block, but it’s not unusual for it to happen.

    Try using the new editor directly instead of using classic blocks, and see if the behavior works differently there. Use a normal paragraph and image block and see what the result is.

    Thread Starter dustsigns

    (@dustsigns)

    To clarify: I am trying to insert a link to a file, not an image. I know that HTML ignores spaces in both cases, which is exactly why I find WordPress’ behavior so counter-intuitive.

    If WordPress cleaned up arbitrarily many spaces, I would understand. If it did not clean them up at all, I would also understand. But always removing exactly one space (even if there is only one!) is counter-intuitive, especially in a WYSIWYG editor.

    Using the new editor is currently not an option for me because I have a ton of old pages which are just classic blocks. From time to time, I need to amend them in the way I described above, where I encounter this behavior a lot.

    • This reply was modified 4 years, 7 months ago by dustsigns.
    • This reply was modified 4 years, 7 months ago by dustsigns.
    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    I tried this on a base setup with the classic block, and I’m unable to reproduce the problem.

    If I type “insert test ” and then hit the link button to insert a link, then the link comes after that final space.

    Similarly, if I type “media test ” and then hit the add media and insert an image, the space remains.

    You say a link to a file, but you said Add Media before. What are you inserting, exactly, that causes the space to be removed? How can I make the problem occur in the simplest way? What steps should I take to see the issue?

    Thread Starter dustsigns

    (@dustsigns)

    I click “Add media”, upload a PDF file and choose “Insert into page”, which creates a link to that PDF that I just uploaded.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Okay, I tried it with a PDF and same result, the space after the text was preserved:

    View post on imgur.com

    Can you try doing it on a site without any plugins and a default theme? Perhaps some plugin you have is interfering. Also, since PDFs are not normally allowed for uploads, maybe whatever plugin you have that is enabling those might be something to look at too.

    Thread Starter dustsigns

    (@dustsigns)

    Interesting. In a vanilla installation with the default theme, I cannot upload any PDFs at all. I was not aware that they are not allowed by default. I do not remember installing any plugins specifically for PDFs, but it seems one of them enables their upload. How can I find out which one it is? I have only a small number of plugins, none of which seems to specifically enable PDF uploads:

    • Broken Link Checker 1.11.12
    • Disable Comments 1.10.2
    • Disable REST API 1.5
    • Enable Media Replace 3.3.11
    • Gallery-Buddy 0.2.9
    • WPvidid Backup Plugin 0.9.38

    The only one that could maybe be related to the issue and the PDF upload in general is Enable Media Replace, but I cannot find any explicit mention of it changing which types of files I can upload. How can I proceed from here to isolate to issue?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding media deletes a preceding space’ is closed to new replies.