Hot answers tagged

21

That’s what getUrl() returns if the transform hasn’t been generated yet. When the browser requests that URL, Craft will generate the transform, and respond with a 302 redirect to the actual image URL. Update: As of Craft 2.2, even if the transform generation URL doesn’t get directly requested (e.g. if it’s a social media image, or a srcset size that doesn’t ...


10

Craft is so flexible there are many ways to do most things, it is up to you to determine what is best for your needs. As far as photo galleries go, there are two main ways that I normally approach this: Method 1: Define asset fields for the images, where you define the photo title and description, etc. These fields are accessed by double clicking the ...


9

It depends heavily on what kind of gallery you're trying to create. For a basic gallery (with maybe meta data) what you describe would be the best way. Pagination would be available for showing grids of images at a time. If you want some kind of album-style organization you can either make the section as a Structure with Album and Photo entry types (photos ...


6

Creating a channel with a matrix field allows you to have more control over the content. For example, I typically use the following: photograph: matrix field image: asset field title: photograph title caption: plain text description: rich text


6

I guess it depends on what information each Asset needs to contain. As you mentioned, a Matrix within a Matrix is not possible, so you will need a different method to attach additional information to each Asset. One method that may work is to create Asset Meta Fields for Assets. This way, you can define additional things on each image on the Asset level. ...


5

That’s definitely the way to do it! I would set the URL segments to their own variables, to clean it up a little bit. {% set entrySlug = craft.request.getSegment(2) %} {% set imageOffset = craft.request.getSegment(4) - 1 %} Also, probably a good idea to include the section param when fetching the entry, in case you have another entry in another section ...


3

I'm a beginner myself but have used assets plenty of times. It should be something like this: {% set entry = craft.entries.section('gallery').first() %} {% set assets = entry.gallery %} {% if assets | length %} {% for asset in assets %} <img src="{{ asset.getUrl('imgTransform') }}" width="{{ asset.getWidth('imgTransform') }}" height="{{ asset....


3

Another option is to create a galleryImage channel (with Entries in this section have their own URLs not checked), and then make your matrix block be a collection of entries in galleryImage added via an Entries field. Each galleryImage would have the image, caption, etc.


3

I've also seen this triggered by directory/file permission issues, namely that Craft didn't have write access to the image asset directory. Once I fixed the permissions with chmod, my specific problem was solved. chmod 777 -R images


3

You can do this by creating a "single image" template, and point to that template with a URL GET variable containing the Asset ID, for example: http://yoursite.com/gallery/single?assetId=234 First, create a template for your "single" image – e.g /templates/gallery/single.twig (I like to use the twig extension rather than .html, but its not important). Add ...


2

There's no real higher limit on Craft itself on the amount of Assets, Entries, Tags, Categories (Elements) etc. that you can store. When reaching a higher limit of actual database entries it'll come down to your hardware and database setup. Speaking to your specific problem 50,000 entries (Assets) are nothing. I'm guessing you might want to organize these ...


1

Rather than having separate entries, have you considered having one type of image but assigning categories or tags to them. That way you could output your images in a random order using .order('RAND()') on the end of your for loop. Something like this: {% for entry in craft.entries.section('yourImageEntries').order('RAND()') %} Then if you want to output ...


1

You can set an array and order them by random. {% set gallery = craft.entries.section(['galleryA','galleryB','galleryC']) %} Then you have to display them by random using .order('RAND()') So your for loop looks like: {% for entry in craft.entries.section(gallery).order('RAND()') %}


1

Ah yes, gallery2. Used that quite extensively a few years ago. Have a client with an old gallery2 project as well, we might be doing something with it, so we're probably in the same boat. I can tell you the last time I looked into the gallery project, they were shutting it down. I have no idea where the project stands now, the original authors wanted ...


1

I was able to figure this out on my own, based off this answer here. Here is the code I ended up using to achieve what I needed, used inside my matrix field. {% if block.type == "featuredProjects" %} {% set relatedEntries = craft.entries.section('projects').relatedTo(block).limit(12) %} {% for entry in relatedEntries %} {% for asset in entry....


1

Something like this might work (obviously, replace the matrixField, assetsField and imageTransform handles with real values): {# Basic query parameters for your sibling entries #} {% set siblingCriteria = craft.entries.section(entry.section.handle) %} {# Creates an array with the next and previous entries, based on the basic query parameters #} {% set ...


1

The {% paginate %} tag requires the ElementCriteriaModel to be passed through first. Since you were requesting entry.images.limit(20) to be paginated, I suspect you have your images set up within a single images asset. Instead you will need to set up your images within a channel or structure if you would like Craft to paginate the gallery between several ...


1

I thought I might fill in a few extra details to support Tom De Smet's excellent answer. If you only need one gallery then as Tom suggested you can change the section type from a channel to a single in the section's settings. Where you choose to display the gallery is completely up to you. It can either be displayed in it's own template (the one you define ...


1

for me trying the happylager template I had to change access to to site dir chmod a+w public/assets/site


1

I have had the same issue when using a custom function to calculate the image's resulting size. The problem happened when that function returned decimals. So if you ever calculate the transform's dimensions, make sure you round the results to avoid this.


1

I also had this problem and changing the setting worked for me. I did have a problem where the transforms then showed a 404 page rather than the actual image. Clearing the 'Cache' via settings in Craft CMS fixed this.


Only top voted, non community-wiki answers of a minimum length are eligible