Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We usually have some concrete directory for saving images (like /public_html/images) and there we store the originals (usually resized to some max. size - say 1024px - upon uploading). There are also subdirectories there, called medium and small (for product detail and small thumbnail for category list). </p> <p>We also store the images using products primary key (if products:images is 1:1) or using PK + id (for 1:N). Then we easily assemble the url in img() view helper like this.</p> <pre><code>public function img($product, $imageId, $size = self::SMALL) { return sprintf('/images/%s/%s_%s.jpg', $size, $product-&gt;id, $imageId); } //in view - can also be wrapped in view helper - depends on your scenario &lt;a href="&lt;?php echo $this-&gt;img($product, 1, 'big');?&gt;"&gt;&lt;img src="&lt;?php echo $this-&gt;img($product, 1, 'small');?&gt;" /&gt;&lt;/a&gt; </code></pre> <p><strong>Edit:</strong> BTW: Actually we never use the originals. We make "big" sized images. </p> <p>The action helper for image resizing is generally a good idea. But depends on how you upload your images - if there is only one action and one controller - there is no need AFAIK. But you may want to upload images also from import, using FTP upload, etc. </p> <p>The linking (if the process described abowe doesn't work well for you) of images via DB falls to two categories - content centric and image centric. </p> <p>You can either go into product editing, where is a button or like "upload a new image" or "link uploaded image". Other option is to have a list of images with "connect to a product". Highly dependable on your users' workflow. </p> <p>Also there are some options how to build your db. You can have image_id in your product table. Or you can have imalelink_id in you product table, which links to M:N table that connects images to products. Also you can have product_id in your image table :) All of these approaches are valid in some cases and wrong in some other. All depends on how the end users will use it. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload