Pregunta

I have a plugin that renders the stream info for my pyrocms site.

I am having issues rendering the image uploaded using the image filetype.

I've tried all of these and none render anything

{{ url:site }}files/thumb/{{ button_img:id }}
{{ button_img:thumb }}
{{ button_img:thumb_img }}
{{ button_img:img }}
{{button_img}}

{{button_img}} renders an id or number "0faaea3a29919c5" in the table this is the ID of the image file row but I need the path or filename.

Is this built into pyro or does the plugin need to join the table?

-------------------------EDIT----------------------------------

Here is the array of info called in using print_r($data) in the plugin

[0] => stdClass Object
        (
            [id] => 2
            [row_id] => 37
            [def_page_fields_id] => 2
            [page_buttons_id] => 2
            [created] => 2014-02-05 16:47:53
            [updated] => 2014-02-05 16:48:07
            [created_by] => 1
            [ordering_count] => 2
            [button_genre] => Visit Us
            [button_hover_text] => Ut eleifend dignissim arcu. Etiam mi velit, pellentesque ac sodales at, iaculis et diam.
            [button_title] => Test Title
            [button_page_link] => /visit-us
            [button_img] => 3dd22710470a16b
        )

How do I call the image.jpg from this info?

<img src="{{ url:site }}files/thumb/{{ button_img:id }}" alt="{{ button_img:name }}"/>

__________________EDIT___________________

Thanks very much for the answer but I'm a bit lost as to where I put the 2 lines of code and what lex should be called.

Here is the plugin code

function getRelationship() {

            $id = $this->attribute('pageid', 1);
        $page_slug =  $this->attribute('pageslug');  
        $linktable =  $this->attribute('linktable');  
            $data = $this->db
            ->select('*')
            ->where($page_slug.'.row_id='.$id)
            ->join($linktable, $linktable.'.id = '.$page_slug.'.'.$linktable.'_id')
            ->get($page_slug)
            ->result();

            //Not sure about this $this->load->library('files/files');
            //$file = Files::get_file($id);

            return $data;



    }

And then my lex tags

{{SitePlugins:getRelationship  pageslug='def_page_fields_page_buttons' pageid=entry_id linktable='page_buttons'}}
<div class=" button_{{id}}">
    <a class="view" href="{{button_page_link}}">
      <h3>{{button_genre}}</h3>
      <h2>{{button_title}}</h2>
    {{ button_img }}
</div>
{{/SitePlugins:getRelationship}}
¿Fue útil?

Solución 2

Here's what ended up working

 <img alt="" class="pyro-image alignment-none" data-pyroimage="true" src="{{ url:site }}files/large/{{team_photo}}" />

Otros consejos

Usually this should work by using the tag {{ field_slug:filename }}. By usually I mean "if you've used the stream entries driver to get the entries".

-- edited --

If you're pulling the data with a custom model, you could use the Files library to get your file data:

$this->load->library('files/files');
$file = Files::get_file($id)

return (array)$file;

This will get you an object with everything the files has. Since the plugin output / LEX parser works with array, you'll have to type cast before returning.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top