WordPress.org

Ready to get started?Download WordPress

Forums

More Fields
Store id instead of absolute URL for file list type (1 post)

  1. wader
    Member
    Posted 2 years ago #

    Currently when using the file list type the plugin saves the "guid" for a image which seams to be the absolute URL for the image. This causes problems when moving between wordpress installations. In my case i have a local development site that is synced to a production site.

    My solution is to store the ID instead of guid and then in the template use wp_get_attachment_url($id) to get the URL. Seams to work fine.

    I don't have much wordpress experience so i don't know if this is a good solution.

    This is with more fields verison 2.1

    Patch:
    --- a/more-fields-field-types.php
    +++ b/more-fields-field-types.php
    @@ -395,7 +395,7 @@
    var htmlth = html;
    var json = eval(\"(\" + response + \")\");
    jQuery.each(json['data'], function(i, file){
    - html = html + '<option value=\"' + file['guid'] + '\">' + file['post_title'] + ' (' + file['post_mime_type'] + ')</option>';
    + html = html + '<option value=\"' + file['ID'] + '\">' + file['post_title'] + ' (' + file['post_mime_type'] + ')</option>';
    htmlth = htmlth + '<option value=\"' + file['ID'] + '\">' + file['post_title'] + ' (' + file['post_mime_type'] + ')</option>';
    });
    if (jQuery('#mf_file_list_thumb_' + clicked)) jQuery('#' + json['clicked'] + '_temp').html(htmlth);
    @@ -418,4 +418,4 @@
    }

    -?>
    \ No newline at end of file
    +?>

    http://wordpress.org/extend/plugins/more-fields/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic