Skip to content

Commit

Permalink
Modified image extraction to allow for size and CSS modifiers (#169)
Browse files Browse the repository at this point in the history
* Modified image extraction to allow for size and CSS modifiers

Image embeds in obsidian can be modified using a pipe syntax.

See:
- https://forum.obsidian.md/t/resize-embedded-content/877/23
- https://www.reddit.com/r/ObsidianMD/comments/v1fs0f/centering_images_in_reading_mode/

Currently, the regex extracts all the pipes as part of the file name, which means any image modified by pipes can't be  displayed in the timeline.
This minor change takes the image name only before the pipe symbol to allow this.

* Removed unnecessary escape character

Fixing ESLint error

* Update cardDataExtraction.ts

* bumped version
  • Loading branch information
oricc committed May 4, 2024
1 parent 4d339df commit 6e76364
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "aprils-automatic-timelines",
"name": "April's Automatic Timelines",
"version": "0.13.2",
"version": "0.13.3",
"minAppVersion": "0.15.0",
"description": "Simple timeline generator for story tellers",
"author": "April Gras",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-auto-timelines",
"version": "0.13.2",
"version": "0.13.3",
"description": "This Obsidian (https://obsidian.md) plugin aims to simplify creating and maintaining timelines in different a project",
"main": "main.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion src/cardDataExtraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function getImageUrlFromContextOrDocument(
const override = metadata?.[metadataKeyEventPictureOverride];

if (override) return override;
const internalLinkMatch = rawFileText.match(/!\[\[(?<src>.*)\]\]/);
const internalLinkMatch = rawFileText.match(/!\[\[(?<src>[^|\]]*).*\]\]/); // Allow for size and CSS modifiers on the image
const externalPictureMatch = rawFileText.match(/!\[.*\]\((?<src>.*)\)/);
let internalLinkIsBeforeExternal = true;
let matches: null | RegExpMatchArray;
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
"0.12.2": "0.15.0",
"0.13.0": "0.15.0",
"0.13.1": "0.15.0",
"0.13.2": "0.15.0"
"0.13.2": "0.15.0",
"0.13.3": "0.15.0"
}

0 comments on commit 6e76364

Please sign in to comment.