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

Filename not visible (field type: file) #118

Closed
phpanos opened this issue Mar 2, 2012 · 17 comments
Closed

Filename not visible (field type: file) #118

phpanos opened this issue Mar 2, 2012 · 17 comments

Comments

@phpanos
Copy link

phpanos commented Mar 2, 2012

Hello!

I have tried the lastest version and the / or the Development version of MF2 on a default theme on wordpress 3.3.1 and the problem is when I upload a file, the filename is not showing up beside the thumbnail right after the text 'file:'. Is this a known issue? Is there a temporary fix for this?

Thanks

/ Panos

@kobobo
Copy link

kobobo commented Mar 8, 2012

This is not a bug. The "file:" comes from the upload input field and is a label.

I did't check what is going on there. If i upload a file, like a pdf file or sth. For which reason do i need a thumbnail? You are right, you need a info what was uploaded. But the upload works.

@phpanos
Copy link
Author

phpanos commented Mar 8, 2012

Thank you for your reply. Yeah, the thumbnail may not be necessary, but I believe the filename is. I'm using this for a project right now, and my customer won't be able to see which file is which when uploading duplicated files. I guess I'll have to add some custom code myself for this. Is there an easy way to append the filename beside the file label? Or could you point me to which file I could try adding my custom code to?

Thanks.

@kobobo
Copy link

kobobo commented Mar 8, 2012

ok, you wanna get the result fast?

@kobobo
Copy link

kobobo commented Mar 8, 2012

a little patch?

@kobobo
Copy link

kobobo commented Mar 8, 2012

go to: plugins/magic-fields-2/field_types/file_field/file_field.php

insert an new line after line 45:

$out .= $field['input_value'];

Not very nice, but helpful.

Better is here(line 58):

$out .= $field['input_value'];
$out .= '';
return $out;

@phpanos
Copy link
Author

phpanos commented Mar 8, 2012

Gonna try it out, give me a sec!

@phpanos
Copy link
Author

phpanos commented Mar 8, 2012

I cannot seem to get the value out of $field['input_value']

@kobobo
Copy link

kobobo commented Mar 8, 2012

ok, uploaded sth? updated the post?

@phpanos
Copy link
Author

phpanos commented Mar 8, 2012

yea I tried your code and uploaded a file, made a var_dump on the $field array as well.

array(16) { ["id"]=> string(1) "8" ["name"]=> string(21) "yttrandee" ["label"]=> string(25) "Uppladdning" ["description"]=> string(21) "Uppladdning av filer." ["post_type"]=> string(6) "remiss" ["custom_group_id"]=> string(1) "5" ["type"]=> string(4) "file" ["required_field"]=> string(1) "0" ["display_order"]=> string(1) "1" ["duplicated"]=> string(1) "0" ["active"]=> string(1) "1" ["options"]=> array(0) { } ["input_name"]=> string(40) "magicfields[yttrandee][1][1]" ["input_id"]=> string(25) "ryttrandee_1_1" ["input_value"]=> string(0) "" ["input_validate"]=> string(0) "" }

@kobobo
Copy link

kobobo commented Mar 8, 2012

ok. if i upload a file, i dont see the value. but if i push the"update" button from the post and save the whole post. I get the result. By the way, is a fast and dirty snippet ;)

@phpanos
Copy link
Author

phpanos commented Mar 8, 2012

Ah! Sorry! I didn't thought you meant update the post =P That works! I know this is a dirty hack, but it will help my customers to see their files. Thank you for your time kobobo. I appreciate your help. If I have time I'll do a javascript solution as well. I see I can get the filename from the data object ^^. Thank you once again!

@kobobo
Copy link

kobobo commented Mar 8, 2012

i try to write the js code, for showing in ajax without saving action...

@kobobo
Copy link

kobobo commented Mar 8, 2012

i send you over if it works...

lets work this filed_type file_field out together ;) I need it soon.

@phpanos
Copy link
Author

phpanos commented Mar 8, 2012

Great! Post it here if you manage to do that :) Good work.

@phpanos
Copy link
Author

phpanos commented Mar 8, 2012

I am working atm and got some stuff to do. I'll look into it if I got some time soon or I'll take a look at it after work :D

@gabor-udvari
Copy link
Contributor

@kobobo, you don't have to write a new AJAX function for this, you can expand file_fields.js to display the filename after a successful upload, eg.:

function mf_file_callback_upload(data){

  if(data.error == false){
    // [...]
    // there's already code displaying things for a successful transfer,
    // we can expand these with something like this (lazy example):
    jQuery('#photo_edit_link_'+data.field_id).append('<br>'+data.file_url);
    // [...]

And this will display the filename right after a successful transmission. (It needs to be more pretty, it's just an example.)

@phpanos
Copy link
Author

phpanos commented Mar 9, 2012

So I have both the JS fix and the PHP fix.
Here's the file_field.js:
http://pastebin.com/48DtTFg2

And here's the file_field.php:
http://pastebin.com/HeMSveHX

I am using the data.name value instead of the whole filepath (data.file_url) on the js solution above.
And yea, a css fix needs to be implemented so that the filename doesn't go over the box.
Good work guys!

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