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

Allow absolute paths in public_folder #1668

Closed
erquhart opened this issue Aug 24, 2018 · 8 comments
Closed

Allow absolute paths in public_folder #1668

erquhart opened this issue Aug 24, 2018 · 8 comments

Comments

@erquhart
Copy link
Contributor

Migrated from #1257 for discussion.

@ahoward
Copy link

ahoward commented Aug 24, 2018

cool. fwiw i am still blocked and would love to see this merged. let me know if/when i can help.

@mryanb
Copy link

mryanb commented Oct 8, 2018

I'm stuck on this too. Our docs are hosted on a sub folder docs.example.com/developer File uploads should be a relative path to /developer. We can include /developer the public_folder setting but then paths are broken for anyone using locally which isn't on a sub folder.

@jballe
Copy link
Contributor

jballe commented Dec 12, 2018

Agree on this one, we would like to have a staging site with Netlify on GitLab pages while the final public site will be on its own domain.

My take so far is that I have replaced ImagePreview with my own implementation that changes the url. This works for preview but I would like to also change the url for the image selector control itself and for images in markdown. A general public absolute url prefix (and suffix), pattern or formatting function would be really helpful.

The code I add to my index.html if anyone can use is below. I ended up creating urls directly to the repo so that I don't have to wait for having the image published to the GitLab pages

    const CustomImagePreview = createClass({
      render: function() {

        var value = this.props.value;
        var getAsset = this.props.getAsset;
        var field = this.props.field;
        var prefix = 'https://gitlab.com/<mygroup>/<myreponame>/raw/master/src/website/static';
        var suffix = '?inline=false';

        var uri = getAsset(value).public_path;
        if(prefix && uri && uri.substring && uri.substring(0, 1) === '/') {
          uri = prefix + uri + suffix;
        }

        var style = { maxWidth: '100%', height: 'auto' };
        return uri ? h('div', { style: style },
          h('img', { src: uri, role: 'presentation' })
        ) : null;
      }
    });

    CMS.registerWidget("image", "image", CustomImagePreview);

@jballe
Copy link
Contributor

jballe commented Dec 13, 2018

Maybe this will actually be solved by #990

@erquhart
Copy link
Contributor Author

That will help with image handling in the CMS, but image path output will still be prepended with public_folder, which will still be absolute.

@stale
Copy link

stale bot commented Oct 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Oct 29, 2019
@erquhart
Copy link
Contributor Author

erquhart commented Jan 7, 2020

@erezrokah how is this impacted by the updates in our image handling?

@erezrokah
Copy link
Contributor

I'm not sure I understand the use case for absolute paths in public_folder. If the use case was just to fix image previews in the CMS, due to recent changes the CMS loads images only using the API and not from the published site.

The only place the public_folder is used is when populating widgets data to be later used by site generators to locate the image in the repository.

Regardless, I've tested setting an absolute URL as a public_folder and it works.

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

5 participants