Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Archive

Markdown relative media url problem

Started by Muut Archive 9 years ago · 0 replies · 500 views
9 years ago

I'm using markdown editor in my template like in this issue: https://getgrav.org/forum#!/general:markdown-editor

My problem is that image linking (resolving relative path) is not working correctly when used from modular on collection pages.

Here is part of partial that I'm using:

TWIG
{% set position = page.header.position %}
  <h2>
    Requirements
  </h2>
  <p>
    {{position.requirements|markdown}}
  </p>

  {{ page.content }}

Here is how I call this partial from parent (modular) (*2):

TWIG
{% for child in page.children %}
    {% set position = child.header.position %}
    <div class="position-container">
      <div class="position-summary" id="{{ position.anchor_id }}">
        <p class="position-name">
          {{position.position}}
        </p>
        <p class="position-location">{{position.location}}</p>
      </div>
      <div class="position-details collapsed">

        {% include 'partials/position.html.twig' with {'page': child} %}

      </div>
    </div>
  {% endfor %}

You may wonder why I use partial - I need this part of code to be used as a list view and as a separate page.

I'm using following test markdown for both page.content and page.header.position.requirements:

TXT
some text

![](P1100338mini.jpg)

some text

So my problem is that when I use this solution for separate page everything works fine - both cases paths are resolved OK, but when I'm using it from modular template (*2) page.content links is resolved correctly but page.header.position.requirements links are resolved incorrectly (path used in page.header is resolved according to CURRENT PAGE url (not file system based but router based(?)).

Correct path to image is http://127.0.0.1:8888/mywebsite/user/pages/06.career/_05_open-positions/super-boy/P1100338mini.jpg
but page.header.position.requirements image path is resolved to http://127.0.0.1:8888/mywebsite/career/P1100338mini.jpg

Is there any way to give markdown filter argument with path to be used? Is there any way to set some global variable to set current working directory to one I want? Am I doing something terribly wrong? :)

THANKS for any help.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1318 9 years ago
Archive · by Muut Archive, 9 years ago
2 915 9 years ago
Archive · by Muut Archive, 9 years ago
2 4044 9 years ago
Archive · by Muut Archive, 9 years ago
1 2920 9 years ago
Archive · by Muut Archive, 9 years ago
3 1104 9 years ago