1

I had a fun time tracking this down. Every time I would copy/paste a link from a site's blog, the title would display, the link would display, but the images would return nothing. The link was correct and clicking the link would take me to the correct post. I went through my settings in NSM Better Meta and included all of the recommended OG meta tags, but still, nothing.

What I found was that by changing my URL of Upload Directory from just "//" to "http://" fixed the issue. That's all fine and dandy, but it doesn't help me keep relative protocols for images. I have both http and https on this site in different locations. It also depends on where they are coming from and if that section of the site has a link that was entered as https. (Not under my control)

Is there any way to set a relative path in the URL of Upload Directory field and have the templates render the path with the protocol from the address bar used?

EXAMPLE: enter image description here

This renders as: enter image description here

Which is correct. I can switch from http: to https: without issues of mixed content.

When I copy the link and paste it in FB, the issue is seen: enter image description here

NOW... Change over to the http: or https: in the settings... enter image description here

This renders as: enter image description here

Which is correct, but not what I want...

When I copy and paste this link into FB, I am given the images... enter image description here

THIS is why I am confused....

1

We forked and modified Bjørn Børresen's SEO Lite module to support basic OG meta tags. The module setting default image still requires an absolute URL; however, for the publish tab and per entry meta, we employed a file upload capability that taps into the native EE file manager and will add a full url dynamically based on file upload settings.

Our changes are open source. Not sure this is the answer you are looking for, but thought I'd share. https://github.com/Minds-On-Design-Lab/modl_meta.ee_addon

| improve this answer | |
  • Thanks. I just updated NSM Better Meta since I was using it though. ;) – W3bGuy Oct 18 '13 at 14:06
1

You can use relative URL paths for you upload directories. Say you images are located at http://example.com/assets/uploads/images/image.jpg you can set your upload url to be relative by entering /assets/uploads/images/ for the uploaded destination url.

Alternatively if you are using something like FocusLab's Master Config file you can use the upload config overrides to set the URL dynamically based upon which protocol/url the user is accessing the site. In your config file you

$protocol                     = (isset($_SERVER['HTTPS']) &&$_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
$base_url                     = $protocol . $_SERVER['HTTP_HOST'];
$base_path                    = $_SERVER['DOCUMENT_ROOT'];
$system_folder                = APPPATH . '../';
$uploads_folder            = 'assets/uploads/';

$env_config['upload_preferences'] = array(
 1 => array(
     'name'        => 'Main Uploads',
     'server_path' => $base_path . '/' . $uploads_folder . 'images/',
     'url'         => $base_url  . '/' . $uploads_folder . 'images/'
 )
);

You would need to repeat that for each upload directories that you have.

| improve this answer | |
  • I am aware I can use them. I was using them in my paths originally. That's why images were not showing up in facebook posts. Once I added the "http:" or "https:" to the beginning, my pasted links were displaying images. I guess I will just have to declare the protocols. :( – W3bGuy Oct 18 '13 at 14:08
  • In that case I would recommend using config overrides because the url protocol for images will be based upon the url the user is currently on – Justin Long Oct 18 '13 at 15:46
  • yeah. That's why I use them. Also why I am having a hard time understanding what the hell is happening. ;) I'll edit the original to provide an example of this, but essentially, if I set the protocol as agnostic in the file preferences, it renders as such. This is when if I copy/paste the link of a page to facebook, no images display or are available. They are only available if I specify a protocol in file manager preferences. – W3bGuy Oct 18 '13 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.