Jump to content

Counter Issues


RChilton

Recommended Posts

So I have product images being added to a website the images are named 77777.jpg or 77777-2.jpg for regular photos and then 77777_1, 77777-2_1, 77777-2_2, etc for the set photos.  Basically I want to restructure our naming of our photos.  Right now the php is using a counter to add the images sequentially.  Now I want to name the set images something like 77777_1a, 77777-2_1a and 77777-2_1d.  Not sure how to change the counter function to add the photos since they are not sequential any more.  The exiting code is below:

if (hasAccessByLevel(6, 'LTE', $userName)){
	echo ("<ul style=\"margin-top:20px;\">
		  <li><a href=\"images/productimages/large_$product[sku].jpg\" class=\"largeImage\">Download large image</a> <em>(right click, save as)</em>
		  </li>");
	if (file_exists("images/productimages/large_$product[sku]_1.jpg")) { //if set photo exists
	  $counter = 0 ;
	  foreach (glob("images/productimages/large_$product[sku]_*.jpg") as $filename) { //Loop through set photos
		  if($counter++ < 0) continue ;
			  echo ("<li><a href=\"images/productimages/large_$product[sku]_$counter.jpg\" class=\"largeImage\">Download large set photo</a>
					 </li>");
		  }
	 }
	 echo ("</ul>");
}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.