forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: MaK_86 on July 26, 2011, 07:41:17 pm

Title: about a custom fields for image description
Post by: MaK_86 on July 26, 2011, 07:41:17 pm
Greating...

I often wonder, if it's possible to make a custom fields for image description like a list from you can choose.
You can make something like a 30 options to bee on the list, and later when uploading a picture, you can select what you mean.

I have a railway photo gallery, so I've thought to make a description like this whith a railway industries.

Hearings...
Title: Re: about a custom fields for image description
Post by: Αndré on July 27, 2011, 10:02:57 am
Open edit_one_pic.php, find
Code: [Select]
if ($CONFIG['user_field1_name'] != '') {

    echo <<< EOT

    <tr>
        <td class="tableb" style="white-space: nowrap;">
            {$CONFIG['user_field1_name']}
        </td>
        <td width="100%" class="tableb" valign="top">
            <input type="text" style="width: 100%" name="user1" maxlength="255" value="{$CURRENT_PIC['user1']}" class="textinput" />
        </td>
    </tr>
EOT;
}
and replace with
Code: [Select]
if ($CONFIG['user_field1_name'] != '') {

    $options_array = array('', 'TABOR ELEKTRYCZNY', 'TABOR SPALINOWY', 'TABOR PAROWY');
    foreach ($options_array as $option) {
        $selected = $CURRENT_PIC['user1'] == $option ? ' selected' : '';
        $options .= "<option{$selected}>{$option}</option>";
    }

    echo <<< EOT

    <tr>
        <td class="tableb" style="white-space: nowrap;">
            {$CONFIG['user_field1_name']}
        </td>
        <td width="100%" class="tableb" valign="top">
            <select name="user1" maxlength="255" class="listbox">{$options}</select>
        </td>
    </tr>
EOT;
}
Title: Re: about a custom fields for image description
Post by: MG on January 05, 2019, 04:07:52 pm
This works great for me. However, is it possible to add this function to "Upload"?
I would like to be able to enter this function when adding a new file as well and be able to choose this custom fields..

all the best
MG
Title: Re: about a custom fields for image description
Post by: Αndré on January 13, 2019, 10:15:13 pm
Open upload.php, find
Code: [Select]
text_box_input($element[0], $element[1], $element[3], $element[4], (isset($element[5])) ? $element[5] : '');and above, add
Code: [Select]
                    if ($element[1] == 'user1') {
                        $options_array = array('', 'TABOR ELEKTRYCZNY', 'TABOR SPALINOWY', 'TABOR PAROWY');
                        foreach ($options_array as $option) {
                            $selected = $CURRENT_PIC['user1'] == $option ? ' selected' : '';
                            $options .= "<option{$selected}>{$option}</option>";
                        }

                        echo <<< EOT

                        <tr>
                            <td class="tableb" style="white-space: nowrap;">
                                {$CONFIG['user_field1_name']}
                            </td>
                            <td width="100%" class="tableb" valign="top">
                                <select name="user1" maxlength="255" class="listbox">{$options}</select>
                            </td>
                        </tr>
EOT;
                        break;
                    }
Title: Re: about a custom fields for image description
Post by: MG on January 14, 2019, 09:44:21 pm
Works great when I use upload option "Simple - one file at a time" Αndré, Thank you so much.

BTW
I'll try to call this funcion in (html5upload): v1.3.6 mod.

In codebase.php from this mod. I find this line:

Code: [Select]
if ($cfg['enabusr1'] && !empty($CONFIG['user_field1_name'])) {
echo '<tr><td class="tableb">'.$CONFIG['user_field1_name'].'</td><td class="tableb"><input type="text" name="user1" id="user1" class="textinput" maxlength="255" style="width:90%" /></td></tr>';
}

and replace to this (copy from edit_one_pic.php) :

Code: [Select]
if ($CONFIG['user_field1_name'] != '') {

    $options_array = array('Wybierz Typ', 'Poster', 'Render', 'Title Treatment', 'Studio Template', 'Stock Image', 'PSD', 'Brush', 'Logo', 'Action', 'Style');
    foreach ($options_array as $option) {
        $selected = $CURRENT_PIC['user1'] == $option ? ' selected' : '';
        $options .= "<option{$selected}>{$option}</option>";
    }

    echo <<< EOT

    <tr>
        <td class="tableb" style="white-space: nowrap;">
            {$CONFIG['user_field1_name']}
        </td>
        <td width="100%" class="tableb" valign="top">
            <select name="user1" maxlength="255" class="listbox">{$options}</select>
        </td>
    </tr>
EOT;
}

I managed to call the drop down list of custom fields, I can choose an option that suits me. However, when I add files and I will be moved to the next page (editpics.php?album =) in places where the name should appear from custom fields, there is nothing. There is an empty table. What could I do wrong?

Additionally, it may be possible to add a drop down list of custom fields when editing files on the page (editpics.php?album =).
Title: Re: about a custom fields for image description
Post by: Αndré on March 14, 2019, 09:36:34 pm
Sorry, but I never used that plugin and won't put any effort into having a closer look at the plugin code. The main difference I can see is, that the input tag contains
Code: [Select]
id="user1"while the select tag in your modification doesn't. Try to add it, maybe it already solves your issue.
Title: Re: about a custom fields for image description
Post by: MG on March 19, 2019, 05:03:01 pm
Works great now Αndré, thank you so much  :)