[wp-hackers] shortcode for images?

Gaarai gaarai at gaarai.com
Fri Jan 30 13:46:18 GMT 2009


All the storage containers are scalars. In other words, you can't have a 
plural field type in SQL.

This means that the only way to store the children into a field is to 
store them in a delimited (comma or otherwise) format. Doing this means 
that the database can no longer perform queries that can load the 
necessary children records. Instead, the software now has to pull the 
required record, look for a non-empty children field, split the field on 
the delimiter, and issue a new query to request each one of those 
records. So, rather than being able to load all of a record's children 
in one query, you now have two queries and some processing logic.

There is the other solution of having a children table which would store 
a pointer to the parent and to a single child. This adds in yet another 
table though and such a solution is typically reserved for multi to 
multi relationships, so it could potentially add nasty issues if plugins 
or bad code improperly modified/added records to the table.

In short, having the parent field is the best solution since it 
minimizes complexity of the database and increases query efficiency.

You may not like it since you prefer to think about the relationship the 
other way around, but it truly is the right way to do the database design.

Chris Jean
http://gaarai.com/
http://wp-roadmap.com/



Jon Mihkkal Inga wrote:
> Hi there.I agree with Paul in that hardcoding the attachment url in posts is
> an obstacle when it comes to portability and customisation.
> If you for example want the attachments to be wrapped in a particular way
> you are forced to use regex or shortcodes in any case and this is extremely
> cumbersome when having to deal with captions that are still shortcodes at
> the time of filtering. I'd also like to point out that the inheritance of
> attachments is a bit awkward. As I understand it, children are found through
> the content of the "post_parent" field. Wouldn't it be cleaner and more
> predictable to have a "post_children" field instead?
> That would surely speed up the get_children call, as it will not need to
> inspect more than one field of post XX to find its children. That would
> perhaps ease performance penalties imposed by not inserting attachment urls
> in posts.
>
> /j
>
> 2009/1/30 scribu <scribu at gmail.com>
>
>   
>>> When you upload an image through the default media upload and you enter a
>>> caption for the image then insert into post what is inserted is something
>>> like:
>>>
>>> [caption id="attachment_2817" align="aligncenter" width="212"
>>> caption="Corporate America More GLBT-Friendly Than Ever."]<a href="
>>> http://www.hrc.org"><img src="
>>> http://blogstaging.hrcsupport.org/wp-content/uploads/2009/01/side.jpg"
>>> alt="Corporate America More GLBT-Friendly Than Ever." title="side"
>>> width="212" height="90" class="size-full wp-image-2817" /></a>[/caption]
>>>
>>> When you view this in the WYSIWYG you will see the image and the caption
>>> text below it. Simple enough.
>>>
>>>       
>> I think shortcode for captions is justified because there isn't a HTML
>> equivalent for them, which is not the case for images.
>>
>> Adding a performance hit of this magnitude just to make a single
>>     
>>> event easier to handle is a poor solution. I also think that it's
>>> barking up the wrong tree.
>>>
>>>       
>> I agree. Speaking of migrations, what would happen if you would want to
>> switch to something other than WP? You would have to use another script to
>> parse the shortcodes, which can lead to other problems.
>>
>> --
>> http://scribu.net
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>>     
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
>   


More information about the wp-hackers mailing list