ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Find replace problem with images

October 09, 2010 2:34pm

Subscribe [2]
  • #1 / Oct 09, 2010 2:34pm

    Crnaovca

    627 posts

    So, I am using channel images module currently and I really like it. Especially support from Brad and such support is something people want when they buy a module. Same thing with EE itself.

    So, I have idea and I am stuck with it on one problem. If anyone have solution for it, I would like to hear it.

    So, when I have text in entry, I can upload images to text with channel images and have them automatically re-sized to given values. That is great. But, what if my client wants to have images IN text using this module.
    I have carefully approached to this idea and I have solution for it but cannot make it work.

    If I use plugin called low_replace (freeware) and channel images module, I can find replace images in text with images from channel images. That is idea. How?

    When someone is writing text, he needs only to put some “imagetags” inside text. Like this:

    “Unless you’ve just arrived in 2009 on a time machine, you know that smoking isn’t good for you. Did you know, that smoking isn’t good for your computer, either? It’s true, at least according to Apple. Two readers in different parts of the country claim that their Applecare warranties were voided due to secondhand smoke. Both readers appealed their cases up to the office of God Steve Jobs himself. Both lost.

    [herecomesimage1]

    Back in April, Derek copied us on his e-mail to Jobs:

      “

      I took my mid 2007 apple macbook (black) into the Jordan Creek Apple Store in West Des Moines, Iowa, on Saturday, April 25th, because I had been experiencing some issues with it overheating, and figured the fan was bad. After some initial testing, they took the computer in for work under my Applecare plan, which has over a year remaining on it.

    [herecomesimage2]


      Today, April, 28, 2008, the Apple store called and informed me that due to the computer having been used in a house where there was smoking, that has voided the warranty and they refuse to work on the machine, due to “health risks of second hand smoke”.

    [herecomesimage3]


      Not only is this faulty science, attributing non smoking residue to second hand smoke, on Chad’s part, no where in your applecare terms of service can I find anything mentioning being used in a smoking environment as voiding the warranty.
      ”
    [herecomesimage4]


    Jobs’ office did not help Derek, but he resolved some of the problems himself by disassembling his Macbook and cleaning it out with a can of compressed air.

    A few months later, reader Ruth wrote to us with an identical complaint after trying to have her son’s iMac repaired at a local authorized repair center.”

    So I have this text and I have put placeholders for images in it.

    I use plugin for find replace and say that I want to replace [herecomesimage] with image URL from channel images.

    I do following

    {exp:channel:entries limit=“1” dynamic=“no” entry_id=“113” }
    
        {exp:low_replace find=”{count_images}” replace=”{number_images}” multiple=“yes”}
    
          {text}
    
        {/exp:low_replace}
    
    {/exp:channel:entries}

    where {count_images} is equal to

    {exp:channel_images:images entry_id=“113”}
          [herecomesimage{image:count}]|
      {/exp:channel_images:images}

    which results in

    [herecomesimage1]|[herecomesimage2]|[herecomesimage3]|[herecomesimage4]|

    and {number_images} is equal to

    {exp:channel_images:images entry_id=“113”}
          {image:url:xl}|
      {/exp:channel_images:images}

    which results in

    image1.jpg|image2.jpg|image3.jpg|image4.jpg|

    (let/s say number of images uploaded is same as images holders in text)


    What is problem!?!?

    if I do it like this

    {exp:channel:entries limit=“1” dynamic=“no” entry_id=“113” }
    
        {exp:low_replace find=”[herecomesimage1]|[herecomesimage2]|[herecomesimage3]|[herecomesimage4]|” replace=“image1.jpg|image2.jpg|image3.jpg|image4.jpg|” multiple=“yes”}
    
          {text}
    
        {/exp:low_replace}
    
    {/exp:channel:entries}

    it works. If I create values dynamically it doesn’t work. Why? How to solve problem? Any idea?

    If it could work as that, that could mean that whole image handling in all entries could be done exclusively with channel images. Not only to create galleries, but to have those images used in text also. And we all know how clients like pictures and don’t know how to optimize them.

    To me this could be better solution than using upload images one by one and optimizing them manually.

    Do not tell me this is plugin or module problem. It is problem of “variables” or whatever in EE. I tried using embed, snippets and so on, and I cannot get it to work.

    Hope this is not too long :D and that I have wrote it understandable.

  • #2 / Oct 12, 2010 7:18am

    Have a look at this post on images within entries, I think you might be able to replace the Matrix fields with channel_images fields.

  • #3 / Oct 12, 2010 12:17pm

    Crnaovca

    627 posts

    Thank you on this post. I was thinking I was only one with this problem. It seems somebody else had same problem as me.

    But, I have seen matrix fields, they act like separate fields. Good one for gallery. Still there is problem of using uploaded pictures inside text not as a separate gallery in entry.

    Such solution exists in Joomla, but I cannot copy paste it here :D . It allows to put “mosimages” as a image placeholder in text where you want image, and when you upload images, you do whatever you want with them - add details, sort them and so on, and when viewing entry on frontpage, all “mosimages” text is replaced with images uploaded in a way they are sorted out. Problem? Images must be optimized in advance. Channel images does that so much better.

    It is a great solution for all people using a lot of images in text. I have tested with at least 20 people using channel_images for that solution and they love it. I just need a way to find-replace that special image placeholder in text and replace it with image in whatever form I need. Only URL, or whole img tag or something else.

    I have found a way but a problem is in a way EE is parsing templates. I cannot get it to work like in a solution above.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases