Boostnote: Image no longer appearing in markdown

Created on 20 May 2018  路  16Comments  路  Source: BoostIO/Boostnote

Current behavior

I expected to see my images after I created the path, however after I updated Boostnote, I can no longer see the image

Expected behavior

I expected to see my images after I created the path.

Steps to reproduce

  1. Add image to to your image folder
  2. Add link in a markdown file
  3. Image will not show

Environment

  • Version : 0.11.5 (0.11.5)
  • OS Version and name : Mac 10.13.4

Images

screen shot 2018-05-20 at 10 22 05 am

screen shot 2018-05-20 at 10 22 16 am

bug

All 16 comments

On Linux (Debian 9.4) it's happening too, i think i found the error, it's trying to find the images on the next path file:///file:////home/user/PATH/attachments/image_name.ext, as you can see, the string duplicate the file:/// protocol, also, the image folder name its looking for attachments instead of images.

This is happening on Mac OS as well...., as @Dario0117 said.

Happening on windows as well (Boostnote Version 0.11.5)

Hi i fear, i broke it by using a new location for the attachments. That has been done because other features are a lot easier to implement if the location of the attachments is /attachments/noteKey.
I did not consider that my change would might break displaying existing attachments/images.
My deepest apologies for that.
The solution would be migrating the attachments to the new location.
Unfortunately i don鈥檛 know where a good place for this migration-method would be. I asked about it in the slack channel. Help is appreciated.. In general migrating should look something like this:

function migrateAttachments (renderedHTML, storagePath, noteKey) {
  if (sander.existsSync(path.join(storagePath, 'images'))) {
    let processedHtml = renderedHTML.replace(new RegExp(mdurl.encode(path.sep), 'g'), path.sep)
    const regexp = new RegExp(STORAGE_FOLDER_PLACEHOLDER + escapeStringRegexp(path.sep) + '[a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)?', 'g')
    const attachments = processedHtml.match(regexp) || []
    if (attachments !== []) {
      createAttachmentDestinationFolder(storagePath, noteKey)
    }
    for (const attachment of attachments) {
      let attachmentBaseName = path.basename(attachment)
      const possibleLegacyPath = path.join(storagePath, 'images', attachmentBaseName)
      if (sander.existsSync(possibleLegacyPath)) {
        const destinationPath = path.join(storagePath, DESTINATION_FOLDER, noteKey, attachmentBaseName)
        sander.copyFileSync(possibleLegacyPath).to(destinationPath)
        renderedHTML = renderedHTML.replace(new RegExp(escapeStringRegexp(path.join(STORAGE_FOLDER_PLACEHOLDER, attachmentBaseName)), 'g'), mdurl.encode(path.join(STORAGE_FOLDER_PLACEHOLDER, noteKey, attachmentBaseName)))
      }
    }
  }
  return renderedHTML
}

I've submitted a PR that might solve the problem by migrating the images to /attachments when displaying the note the first time. The images should be visible then again. But some other features (like removing un-referenzed attachments) will not work with that solution.

Could you test, if that PR solves you issue please?

In this version, I can't see the previous images added, which is in 'images' folder.
And also, if i paste the image captured in clipboard, the image will appeare in 'attachment' folder and after a few seconds, it is deleted automatically. What's the problem

Hi @MeteorKepler
Thanks for your feedback.
The first is answered by https://github.com/BoostIO/Boostnote/issues/1941#issuecomment-390644169
The second is answered by https://github.com/BoostIO/Boostnote/issues/1953#issuecomment-390886100

I hope that i fixed the problems by my PR. It will be reviewed and tested and i hope that a new version with the fix will be released soon

Ok, hope it will be updated soon. And better to change the absolute path to relevant because of sync between devices

@MeteorKepler what do you mean? AFAIK all path are meant to be relative. Absolute paths (like mentioned in https://github.com/BoostIO/Boostnote/issues/1953#issuecomment-390886100 were a mistake and not intended..

Yes, i mean it in #1953.

Okay. As you can see i submitted a commit in my PR that should make the paths relative (as intended).. :)

Just wondering the status on this bug? Will the fix be included in the next boostnote update?

@chethanjjj One of the comments of #1980 say this issue is resolved by #2107 . This pr is included in next version(v0.11.7). Please wait for release next version.

I am using version 0.11.9 and I am still having the problem. My link is pointing to an image file URL, though.

what does

My link is pointing to an image file URL, though.

that mean? Can you provide your note content (resp. the part with the image)?? @haisongdong-harrison

Oh wait, I think I know what's my problem...
I used a link that I thought is an image file, for example: https://github.com/BoostIO/Boostnote/blob/master/resources/repository/top.png
But actually, it's not the file. This is
https://raw.githubusercontent.com/BoostIO/Boostnote/master/resources/repository/top.png

Never mind.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ysshah picture ysshah  路  3Comments

shunchuan picture shunchuan  路  3Comments

NourEldin275 picture NourEldin275  路  3Comments

cyber-arsenull picture cyber-arsenull  路  3Comments

NonlinearFruit picture NonlinearFruit  路  3Comments