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

Fix image insertion behavior #1143

Merged
merged 3 commits into from
Jan 15, 2024
Merged

Fix image insertion behavior #1143

merged 3 commits into from
Jan 15, 2024

Conversation

babbitt
Copy link
Member

@babbitt babbitt commented Jan 11, 2024

Various fixes related to image uploading & insertion:

Broken image uploading behavior if media is set in _config.yml

It appears that when 29b0f35 was merged, it accidentally broke image uploading if you've specified a media folder in your _config.yml.

How to reproduce

  1. Edit a repo with a _config.yml that specifies a media folder as well as at least one recognized image file within config.media.
  2. Attempt to upload a photo
  3. src is [Object object]/{file}

The updateImageInsert function was determining path by prepending assets which is an object of all uploaded files, not the config.media path. This would result in the upload url being [Object object]/path when using the media uploader.

This fix

  • Resolves this error by reinstating use of the defaultUploadPath function (reused from the default file upload code)

Un-buildable metadata as result of image form use

When an image was uploaded to/selected from the modal in the metadata section, the value was prepended with {{site.baseurl}} which is improper as jekyll will not parse liquid syntax in front matter. A side affect of fixing this behavior is that image urls hosted externally now insert properly (as requested in #842 & #1019)

How to reproduce

  1. Insert an external image url eg. https://example.com/logo
  2. Inserted markdown is `{{site.baseurl}}/https://example.com/logo``
    or
  3. Inset an image (internal or external) via the metadata view
  4. Inserted path is {{site.baseurl}}/asset

This fix

  • Uses absolute paths in metadata (since Jekyll does not parse front matter)
  • Checks for external urls when inserting via the toolbar (starts with http[s]:https://)

Additionally I dd the following maintenance while I was poking around

Although I tried to spend considerable time getting testing nailed down for this change, the lack of testing infra for toolbar & assetselection made this a no go. The good news is that defaultUploadPath has tests already (which are passing)

@babbitt babbitt changed the title fix image directory upload issue when media is present in _config.yml Fix image insertion behavior Jan 13, 2024
@babbitt
Copy link
Member Author

babbitt commented Jan 13, 2024

Force push to babbitt@a15b01f due to unforseen issues with es6 conflicts (use of const)

@babbitt babbitt mentioned this pull request Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant