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

Media's url(…) should offer include_host-Parameter #894

Open
MaZderMind opened this issue Jun 12, 2016 · 7 comments
Open

Media's url(…) should offer include_host-Parameter #894

MaZderMind opened this issue Jun 12, 2016 · 7 comments

Comments

@MaZderMind
Copy link

MaZderMind commented Jun 12, 2016

A [Media's url(…) Method](https://learn.getgrav.org/content/media#url) does not offer a include_host`-Parameter like the Page-Object does.

Furthermore there seems no other way to add the Hostname to a Media's URL.

@MaZderMind
Copy link
Author

Skip the last Paragraph, one can prepend uri.base. But the API should closer mimic the Pages' API which offers this option.

@rhukster
Copy link
Member

Pretty sure this already takes into account the system.yaml based absolute_urls setting.

@MaZderMind
Copy link
Author

Yes, probably. I needed it here for a Pinterest sharing link, which needs the hostname but just in this place.

@flaviocopes
Copy link
Contributor

Can you explain the use case in details, to understand what's the problem and how did you expect it to work?

@rhukster
Copy link
Member

I think he programmatically want's to flag a particular media URL to use full URL rather than using whatever the default style is.

so:

{{ page.media['someimage.jpg'].url(true) }}

To provide a full http://yourhost.com/yourpage/someimage.jpg type URL for this media item.

@MaZderMind
Copy link
Author

@rhukster exactly. My Use-Case currently looks like this:

{% set url = uri.url(true) | url_encode %}
{% set desc = page.title | url_encode %}
{% set image = (uri.base ~ (page.media.images | first).url) | url_encode %}

<a class="pinterest" href="https://pinterest.com/pin/create/button/?url={{ url }}&amp;media={{ image }}&amp;description={{ desc }}" data-width="1200" data-height="630">
    Pinterest
</a>

I had expected for media..url to have a include_host parameter, symmetrical to uri.url.

@flaviocopes
Copy link
Contributor

Ok got it, you can do via absolute_urls: true, but turns on for all images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants