Forum for discussing general topics related to Couch.
11 posts Page 1 of 2
Sorry, I thought I had posted this but cant find it in the forums, so if duplicated forgive me.

Can
Code: Select all
<cms:thumbnail my_pic width='100' height='100' />


work inside a "repeatable" region? It seems to just not display the image :(

i.e.

Code: Select all

<cms:show_repeatable 'my_pics' startcount='1'>
<img src="<cms:thumbnail my_pic width='100' height='100' />" class="full-width-image" />
</cms:show_repeatable>   
Read the yellow box: http://www.couchcms.com/docs/concepts/repeatable-regions.html

Short answer, type 'thumbnail' editable regions don't work in repeatable regions. As in... the following code would be incorrect:
<cms:repeatable name='pictures'>
<cms:editable name='picture' type='image'/>
<cms:editable name='picture_thumb' assoc_field='picture' width='200' type='thumbnail'/>
</cms:repeatable>

<cms:show_repeatable 'pictures'>
<img src="<cms:show picture_thumb/>">
</cms:show_repeatable>


Ditch the 'thumbnail' editable and use the 'thumbnail' tag as a replacement:
<cms:repeatable name='pictures'>
<cms:editable name='picture' type='image'/>
</cms:repeatable>

<cms:show_repeatable 'pictures'>
<img src="<cms:thumbnail picture width='200'/>">
</cms:show_repeatable>


Just in case there is no misunderstanding, type 'thumbnail' editables don't need to be used with the 'thumbnail' tag... It is redundant.
Hi cheesypoof,

Just to clarify, I'm not using thumbnails as an editable region - I dont see the point, thats just me and I've been implementing timthumb for long enough to just tell clients to use the right aspect ratio.

However, and apologies if I am misundertanding you, but trying to pull a standard "image" field type in a repeatable and "thumbnail" it is not working.

Below, a more specific example:



Code: Select all
<cms:show_repeatable 'my_photos' startcount='1'>
<img src="<cms:thumbnail my_photo width='200' />" alt="<cms:show k_page_title />" />
</cms:show_repeatable>   


with this as my editable declaration:

Code: Select all

<cms:repeatable name='my_photos'>
  <cms:editable type='image' name='my_photo' label='My Photo' show_preview='1' preview_width='150' input_width='200' col_width='300' />
</cms:repeatable>
Apologies for the unnecessary lecture then. :P

I hadn't noticed it before, but it could be that startcount should be start_count instead?
No worries :)

Code: Select all
 ... startcount='1'>
is necessary in my setup because I'm outputting the repeatable images into a carousel slider, it's the only way I have found to limit / select the first image as the primary slide (active state in Twitter Bootstrap) or cover / album image in a clonable page that's not a gallery.

I can confirm using the code I have is only pulling in a single "first" image from the repeatable.
if i implment this code inside my repeatable loop with the startcount

Code: Select all
<cms:thumbnail my_photo width='50' />


I get a broken image link like this:

http://mydomain.com/uploads/image/foldername/imagename-50x28.jpg


if that helps - it seems to try and create the thumb e.g. the 50x28 proportionate scaling but nothing shows / displays as an image.
I grasp that you need the count to start at 1 instead of 0. What I meant is that I was under the impression that the parameter name was 'start_count' not 'startcount'. I don't think I would have used 'start_count' previously if it wasn't in the documentation as so. Now however it appears to use 'startcount', so I'm lost for an explanation.

Nevertheless, if it is outputting code for at least one image correctly, then it may be a logic error with your 'if' tags.

You replied saying that it still does give you a thumbnail URL for count > 1, but the actual file does not exist. If that is the case, it could be a permissions issue, but I can't explain why your first image would be saved correctly but not any subsequent ones.
Firstly, I think there is some confusion regarding the 'startcount' parameter. Please allow me to get that right -
As the 'show_repeatable' tag iterates through the rows in the repeatable region, it sets a variable named 'k_count' to show the number of the row being iterated. Thus, for example, if there are 4 images in your repeatable region (i.e. 4 rows), the 'k_count' will begin from '1' and increase upto '4'.

The 'startcount' parameter merely serves to set the first value of 'k_count' from the default of '1' to any other value (e.g. if set to '0', k_count will increase as 0,1,2 and 3).
It does not affect the number of rows being fetched or the first row being displayed - all the rows present will be fetched and in the order that they appear in the admin-panel (where you can manually set their order).

That said, coming to the problem on hand -
Your code seems perfectly OK to me.
You said using
<cms:thumbnail my_photo width='50' /> gave a broken link http://mydomain.com/uploads/image/foldername/imagename-50x28.jpg.

Can you please confirm that the image imagename-50x28.jpg is indeed not physical present on the server (i.e. not created)? (take a look using FTP if required).
If yes, there has to be some permission issue etc. as the code is ok and should work.

Please let me know.
We'll deal with displaying only a particular row once we sort this out.
@KK - it was a permissions issue, Doh! I had completely forgotten that when moving the site recently from one server to another I have to set 777 perms not 755 (which works on the other hosting provider). Because I had not been uploading anything this issue wasn't clear to me, I would have clocked it sooner had I uploaded something.

I have removed the 'startcount' because as you've explained the default is 1 therefore including it is redundant, I am just using
<cms:if k_count =='1'>
to limit to one row been fetched. Expression Engine has a module called "Matrix" which is pretty much the same as repeatables however that module limits the rows fetched in the opening tag i.e.

Code: Select all
{matrix_fieldtype limit="1"}
{my_fieldtype}
{/matrix_fieldtype}


Am I just been fussy if I put a feature request in for repeatable to have this simple limit making the if k_count unnecessary?
Am I just been fussy if I put a feature request in for repeatable to have this simple limit making the if k_count unnecessary?

Not at all :) I have put that down in the todo list. Thanks.
11 posts Page 1 of 2
cron