ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Image not displaying in Safecracker

February 07, 2012 4:51pm

Subscribe [1]
  • #1 / Feb 07, 2012 4:51pm

    spcejunk

    27 posts

    Hello,

    I’m having a problem getting a simple edit image info form to work. Actually, the form works just fine, but we’re not able to display the image next to the form. Here’s the template code

    {exp:safecracker channel="photos" return="photos/" entry_id="{segment_3}"}
    <input type="hidden" name="title" id="title" value="{username}">
    
    {if photo_1 != ""}
      
    <label for="title_1">Title</label>
    
    <input name="title_1" id="title_1" value="{photo_1}" type="text">br >
    {photo_1}
     (doesn't work here)
    <label for="caption_1">Caption</label>
    
    <textarea name="caption_1" id="caption_1" rows="5' type="text">{caption_1}</textarea><br >
    
    {/if}
    
    
    <input type="submit" value="Submit">               
                 
    {/exp:safecracker}

    That image tag ends up looking something like this…

    https://ellislab.com/asset/images/pronet-logo/image_name.jpg

    So, the filedir isn’t getting converted before the html ends up in the browser. All other custom fields are just fine. {photo_1} is a Safecracker file field type.

    Any suggestions?

    (EE 2.3.1)

  • #2 / Feb 08, 2012 3:22pm

    Dan Decker

    7338 posts

    Hi spcejunk,

    In order to have SafeCracker process some channel field tags, you have to wrap your {exp:safecracker} tags in {exp:channel:entries} tags.

    {exp:channel:entries channel="photos" entry_id="{segment_3}"}
    {exp:safecracker return="photos/"}
    <input type="hidden" name="title" id="title" value="{username}">
    
    {if photo_1 != ""}
      
    <label for="title_1">Title</label>
    
    <input name="title_1" id="title_1" value="{photo_1}" type="text">br >
    {photo_1}
     (doesn't work here)
    <label for="caption_1">Caption</label>
    
    <textarea name="caption_1" id="caption_1" rows="5' type="text">{caption_1}</textarea><br >
    
    {/if}
    
    
    <input type="submit" value="Submit">               
                 
    {/exp:safecracker}
    {/exp:channel:entries}

    Without the channel entries tags, SafeCracker outputs the *value* stored in the field and not the parsed output like you are expecting.

    Cheers!

     

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases