Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter michaeledi

    (@michaeledi)

    Hi,
    I have managed to solve that by changing the code in gravity-forms-ajax-upload-list-field.php,
    change the
    $column = "<a href='{$file_url}' target='_blank' >{$external_url}</a>"; to
    $column = "<a href='{$file_url}' target='_blank' >{$file_name_decode}</a>";
    Thanks to your code, it’s really clear and readable ??

    • This reply was modified 7 years, 11 months ago by michaeledi.
    Plugin Author ovann86

    (@ovann86)

    Hey,

    It’s curious it’s getting through to the external url part.

    Looking right before the line you pointed out, I’m seeing that this is failing pass run when it should

    if ( substr( $file_url, 0, strlen( site_url() ) ) === site_url() ) { // if URL belongs to same website treat link as file

    Which I now see as a hideously over complicated way of working out if it’s the same host.

    Although it worked before and I suspect that site_url() has changed because it now returns the site_url with a backslash at the end.

    Any how, to fix this up I’ll replace it with this code in a soon to be released update

    $file_url_parse = parse_url( $file_url );
    $site_url_parse = parse_url( site_url() );
    if ( $file_url_parse['host'] === $site_url_parse['host'] ) { // if URL belongs to same website treat link as file

    Should be much more reliable.

    Thanks for raising this and finding what was going wrong.

    Thread Starter michaeledi

    (@michaeledi)

    Hi,
    Thanks for the explanation, I think it might be my CDN settings that caused the problem, since the upload path is to another domain…
    Anyway, could you check my another question regarding the dragging issue?
    Thanks!

    Plugin Author ovann86

    (@ovann86)

    Ah – yes, I was wondering that as well.

    Hmm, so yes there is a problem and no it still wont fix it in this case.

    I’m thinking we should be able to drop in a filter here to help instead of having to edit the code each time there’s an update. I dont think it’s as simple as a filter for the $site_url_parse[‘host’] – because a CDN might change the host frequently.

    Plugin Author ovann86

    (@ovann86)

    With your upload paths, do you think it’s possible to narrow it down to a list of ‘hosts’ (subdomain and domain name)?

    I could setup a filter that lets you provide all your possible hosts, then you can dump the filter where you put your custom code instead of editing the plugin.

    For example, cdn1.cndwebsite.com, cdn2.cndwebsite.com etc

    Thread Starter michaeledi

    (@michaeledi)

    Wow, that will be great! The CDN I used is not changed frequently, I mapped it to my subdomain, so yes, it’s almost fixed to a specific domain.
    Thanks for your help very much!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Renaming the download link for uploaded files in the admin panel’ is closed to new replies.